2019牛客暑期多校训练营(第六场)

Problem A Garbage Classification

https://ac.nowcoder.com/acm/contest/886/A

题意:

题解:模拟

C++版本一

/*
*@Author:   STZG
*@Language: C++
*/
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
char str[N],ss[27];
struct node{};
string s[4]={"Harmful","Recyclable","Dry","Wet"};
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    scanf("%d",&t);
    int T=0;
    while(t--){
        scanf("%s%s",str,ss);
        int len=strlen(str);
        a[0]=a[1]=a[2]=0;
        for(int i=0;i=len){
            cout<=2*a[1]){
            cout<

Problem B Shorten IPv6 Address

https://ac.nowcoder.com/acm/contest/886/B

题意:

题解:模拟

C++版本一

/*
*@Author:   STZG
*@Language: C++
*/
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int cnt,flag,temp,sum;
int a[N];
char str[N];
char tmp[N];
struct node{

    string val;
    bool operator <(const node S)const{
        if(S.val.size()==val.size()){
            return val=1){
                    cnt++;
                    ans[cnt].val="";
                    for(int j=0;j<8;j++){
                        sprintf(tmp,"%x",a[j]);
                        if(l

Problem C 

 

题意:

题解:

C++版本一

 

Problem D Move

https://ac.nowcoder.com/acm/contest/886/D

题意:

题解:

C++版本一

/*
*@Author:   STZG
*@Language: C++
*/
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=1000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
int vis[N];
char str;
struct node{};
bool sloved(int mid){
    memset(vis,0,sizeof(vis));
    cnt=0;
    for(int i=1;i<=k;i++){
        int now=mid;
        for(int j=n;j>=1;j--){
            if(now>=a[j]&&!vis[j]){
                now-=a[j];
                vis[j]=1;
                cnt++;
            }
        }
        if(cnt>=n)break;
    }
    return cnt>=n;
}
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    scanf("%d",&t);
    int T=0;
    while(t--){
        scanf("%d%d",&n,&k);
        sum=0;
        int maxl=0;
        for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum+=a[i],maxl=max(maxl,a[i]);
        sort(a+1,a+n+1);
        l=max(maxl,(int)ceil(sum/k));
        r=sum;
        ans=sum;
        for(int i=l;i<=r;i++)if(sloved(i)){ ans=i;break;}
        cout<<"Case #"<<++T<<": "<

Problem E 

 

题意:

题解:

C++版本一

 

Problem F 

 

题意:

题解:

C++版本一

 

Problem G 

 

题意:

题解:

C++版本一

 

Problem H 

 

题意:

题解:

C++版本一

 

Problem I 

 

题意:

题解:

C++版本一

 

Problem J Upgrading Technology

https://ac.nowcoder.com/acm/contest/886/J

题意:

题解:

C++版本一

你可能感兴趣的:(#,C++,#,2019牛客暑期多校训练营,C++,ACM,2019牛客暑期多校训练营)