• Codeforces Round #640 (Div. 4)


    A

    简单模拟

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 int a[17];
     5 int b[17];
     6 int main(){
     7     ios::sync_with_stdio(false);
     8     cin.tie(NULL);
     9     cout.tie(NULL);
    10     int t;
    11     cin>>t;
    12     while(t--){
    13         int n;
    14         cin>>n;
    15         int cnt=0;
    16         int num=0;
    17         while(n){
    18             ++num;
    19             if(n%10==0){
    20                 n/=10;
    21                 continue;
    22             }
    23             a[++cnt]=n%10;
    24             b[cnt]=num;
    25             n/=10;
    26         }
    27         cout<<cnt<<"
    ";
    28         for(int i=1;i<=cnt;++i){
    29             cout<<a[i];
    30             int x=b[i]-1;
    31             while(x--)
    32                 cout<<0;
    33             cout<<" ";
    34         }
    35         cout<<"
    ";
    36     }
    37     return 0;
    38 }

    B

    简单枚举

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 int main(){
     5     ios::sync_with_stdio(false);
     6     cin.tie(NULL);
     7     cout.tie(NULL);
     8     int t;
     9     cin>>t;
    10     while(t--){
    11         int n,k;
    12         cin>>n>>k;
    13         int flag=0;
    14         if(n>=2*k){
    15             int x=n-2*(k-1);
    16             if(x%2==0){
    17                 flag=1;
    18                 cout<<"YES
    ";
    19                 for(int i=1;i<k;++i)
    20                     cout<<"2 ";
    21                 cout<<x<<"
    ";
    22             }
    23         }
    24         if(!flag&&n>=k){
    25             int x=n-(k-1);
    26             if(x&1){
    27                 flag=1;
    28                 cout<<"YES
    ";
    29                 for(int i=1;i<k;++i)
    30                     cout<<"1 ";
    31                 cout<<x<<"
    ";
    32             }
    33         }
    34         if(flag==0)
    35             cout<<"NO
    ";
    36     }
    37     return 0;
    38 }

    C

    简单计数

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 int main(){
     5     ios::sync_with_stdio(false);
     6     cin.tie(NULL);
     7     cout.tie(NULL);
     8     int t;
     9     cin>>t;
    10     while(t--){
    11         long long n,k;
    12         cin>>n>>k;
    13         long long x=n-1;
    14         long long y=k/x;
    15         long long ans=y*n;
    16         long long z=k%x;
    17         if(z==0)
    18             --ans;
    19         else
    20             ans+=z;
    21         cout<<ans<<"
    ";
    22     }
    23     return 0;
    24 }

    D

    简单模拟

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 int a[1007];
     5 int main(){
     6     ios::sync_with_stdio(false);
     7     cin.tie(NULL);
     8     cout.tie(NULL);
     9     int t;
    10     cin>>t;
    11     while(t--){
    12         int n;
    13         cin>>n;
    14         for(int i=1;i<=n;++i)
    15             cin>>a[i];
    16         int cnt=0;
    17         int l=1,r=n;
    18         int sum1=0,sum2=0;
    19         int ans1=0,ans2=0;
    20         while(1){
    21             if(l>r)
    22                 break;
    23             if(cnt%2==0){
    24                 ++cnt;
    25                 int x=0;
    26                 while(l<=r){
    27                     x+=a[l++];
    28                     if(x>sum2)
    29                         break;
    30                 }
    31                 ans1+=x;
    32                 if(x<=sum2)
    33                     break;
    34                 else
    35                     sum1=x;
    36             }
    37             else{
    38                 ++cnt;
    39                 int x=0;
    40                 while(r>=l){
    41                     x+=a[r--];
    42                     if(x>sum1)
    43                         break;
    44                 }
    45                 ans2+=x;
    46                 if(x<=sum1)
    47                     break;
    48                 else
    49                     sum2=x;
    50             }
    51         }
    52         cout<<cnt<<" "<<ans1<<" "<<ans2<<"
    ";
    53     }
    54     return 0;
    55 }

    E

    简单枚举

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 int a[8007];
     5 int vis[8007];
     6 int main(){
     7     ios::sync_with_stdio(false);
     8     cin.tie(NULL);
     9     cout.tie(NULL);
    10     int t;
    11     cin>>t;
    12     while(t--){
    13         int n;
    14         cin>>n;
    15         for(int i=1;i<=n;++i){
    16             cin>>a[i];
    17             vis[i]=0;
    18         }
    19         if(n==1){
    20             cout<<"0
    ";
    21             continue;
    22         }
    23         for(int i=1;i<n;++i){
    24             int sum=a[i];
    25             for(int j=i+1;j<=n;++j){
    26                 sum+=a[j];
    27                 if(sum>n)
    28                     break;
    29                 vis[sum]=1;
    30             }
    31         }
    32         int cnt=0;
    33         for(int i=1;i<=n;++i)
    34             if(vis[a[i]])
    35                 ++cnt;
    36         cout<<cnt<<"
    ";
    37     }
    38     return 0;
    39 }

    F

    简单构造

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 char ans[1007];
     5 int main(){
     6     ios::sync_with_stdio(false);
     7     cin.tie(NULL);
     8     cout.tie(NULL);
     9     int t;
    10     cin>>t;
    11     while(t--){
    12         int a,b,c;
    13         cin>>a>>b>>c;
    14         if(b==0){
    15             while(a){
    16                 cout<<'0';
    17                 --a;
    18                 if(a==0)
    19                     cout<<'0';
    20             }
    21             while(c){
    22                 cout<<'1';
    23                 --c;
    24                 if(c==0)
    25                     cout<<'1';
    26             }
    27             cout<<"
    ";
    28             continue;
    29         }
    30         int cnt=0;
    31         ans[++cnt]='0';
    32         while(b>1){
    33             ans[++cnt]='1';
    34             ans[++cnt]='0';
    35             b-=2;
    36         }
    37         if(b>0)
    38             ans[++cnt]='1';
    39         while(a){
    40             cout<<'0';
    41             --a;
    42         }
    43         cout<<ans[1];
    44         while(c){
    45             cout<<'1';
    46             --c;
    47         }
    48         for(int i=2;i<=cnt;++i)
    49             cout<<ans[i];
    50         cout<<"
    ";
    51     }
    52     return 0;
    53 }

    G

    简单构造

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 int main(){
     5     ios::sync_with_stdio(false);
     6     cin.tie(NULL);
     7     cout.tie(NULL);
     8     int t;
     9     cin>>t;
    10     while(t--){
    11         int n;
    12         cin>>n;
    13         if(n<4)
    14             cout<<"-1
    ";
    15         else if(n%4==0||n%4==1){
    16             int x=n/4;
    17             int y=n%4;
    18             for(int i=1;i<=x;++i)
    19                 cout<<4*(i-1)+2<<" "<<4*(i-1)+4<<" "<<4*(i-1)+1<<" "<<4*(i-1)+3<<" ";
    20             if(y>0)
    21                 cout<<n;
    22             cout<<"
    ";
    23         }
    24         else if(n%4==2){
    25             int x=n/4;
    26             cout<<"1 3 5 2 6 4 ";
    27             for(int i=2;i<=x;++i)
    28                 cout<<4*(i-1)+4<<" "<<4*(i-1)+6<<" "<<4*(i-1)+3<<" "<<4*(i-1)+5<<" ";
    29             cout<<"
    ";
    30         }
    31         else if(n%4==3){
    32             int x=n/4;
    33             cout<<"2 6 4 1 3 7 5 ";
    34             for(int i=2;i<=x;++i)
    35                 cout<<4*(i-1)+5<<" "<<4*(i-1)+7<<" "<<4*(i-1)+4<<" "<<4*(i-1)+6<<" ";
    36             cout<<"
    ";
    37         }
    38     }
    39     return 0;
    40 }
  • 相关阅读:
    Ubuntu中文乱码问题解决方案
    微软开业网站----精华 http://www.microsoft.com/opensource/directory.aspx
    微软开源项目
    cnblogs开源合集
    微软开源软件---管理员用的软件
    微软开源项目-codeflex项目介绍
    SQLServer 微软团队开源项目 (web 版?)
    流程引擎2-CCFLOW
    流程引擎1-高人
    sql web Admin 源码.net 升级
  • 原文地址:https://www.cnblogs.com/ldudxy/p/12865759.html
Copyright © 2020-2023  润新知