• code+11月月赛


    T1 SB题

     1 #include<cstdio> 
     2 #include<cstring>
     3 #include<cmath>
     4 #include<ctime>
     5 #include<iostream>
     6 #include<algorithm>
     7 #include<queue>
     8 #include<set>
     9 #define inf (0x7fffffff)
    10 #define l(a) ((a)<<1)
    11 #define r(a) ((a)<<1|1)
    12 #define b(a) (1<<(a))
    13 #define rep(i,a,b) for(int i=a;i<=(b);i++)
    14 #define clr(a) memset(a,0,sizeof(a))
    15 typedef long long ll;
    16 typedef unsigned long long ull;
    17 using namespace std;
    18 ll a,b,c;
    19 ll gcd(ll x,ll y){
    20     return y?gcd(y,x%y):x;
    21 }
    22 int main(){
    23     scanf("%lld%lld%lld",&a,&b,&c);
    24     ll t=a/gcd(a,b)*b;
    25     cout<<c/gcd(t,c)*t<<endl;
    26     return 0;
    27 }
    View Code

    T2 Sort贪心 注意边界和特殊情况

     1 #include<cstdio> 
     2 #include<cstring>
     3 #include<cmath>
     4 #include<ctime>
     5 #include<iostream>
     6 #include<algorithm>
     7 #include<queue>
     8 #include<set>
     9 #define inf (0x7fffffff)
    10 #define l(a) ((a)<<1)
    11 #define r(a) ((a)<<1|1)
    12 #define b(a) (1<<(a))
    13 #define rep(i,a,b) for(int i=a;i<=(b);i++)
    14 #define clr(a) memset(a,0,sizeof(a))
    15 typedef long long ll;
    16 typedef unsigned long long ull;
    17 using namespace std;
    18 const int maxn=200009;
    19 ll n,S,L,sum[maxn],H[maxn];
    20 struct tree{
    21     ll h,a,m;
    22     inline bool operator<(const tree T)const{
    23         return m<T.m||(m==T.m&&a<T.a);
    24     }
    25 }t[maxn];
    26 int main(){
    27     scanf("%lld%lld%lld",&n,&S,&L);
    28     rep(i,1,n) scanf("%lld",&t[i].h);
    29     rep(i,1,n) scanf("%lld",&t[i].a);
    30     rep(i,1,n) t[i].m=L<=t[i].h?0:(L-t[i].h)/t[i].a+ll((L-t[i].h)%t[i].a!=0);
    31     sort(t+1,t+n+1);
    32     rep(i,1,n){
    33         sum[i]=sum[i-1]+t[i].a;
    34         H[i]=H[i-1]+t[i].h;
    35     }
    36     bool flag=0;
    37     rep(i,1,n){
    38         ll tmp=t[i].m*sum[i]+H[i];
    39         if(tmp>=S){
    40             flag=1;
    41             if(i==1) cout<<max(t[1].m,S<=H[1]?0:(S-H[1])/t[1].a+ll((S-H[1])%t[1].a!=0))<<endl;
    42             else cout<<min(t[i].m,(S-H[i-1])/sum[i-1]+ll((S-H[i-1])%sum[i-1]!=0))<<endl;
    43             break;
    44         }
    45     }
    46     if(!flag) cout<<(S<=H[n]?0:(S-H[n])/sum[n]+ll((S-H[n])%sum[n]!=0))<<endl;
    47     return 0;
    48 }
    View Code

    T3 DP 我tm把m打成n 一直wa

     1 #include<cstdio> 
     2 #include<cstring>
     3 #include<cmath>
     4 #include<ctime>
     5 #include<iostream>
     6 #include<algorithm>
     7 #include<queue>
     8 #include<set>
     9 #define inf (0x3f3f3f3f)
    10 #define l(a) ((a)<<1)
    11 #define r(a) ((a)<<1|1)
    12 #define b(a) (1<<(a))
    13 #define rep(i,a,b) for(int i=a;i<=(b);i++)
    14 #define clr(a) memset(a,0,sizeof(a))
    15 typedef long long ll;
    16 typedef unsigned long long ull;
    17 using namespace std;
    18 int readint(){
    19     int t=0,f=1;char c=getchar();
    20     while(!isdigit(c)){
    21         if(c=='-') f=-1;
    22         c=getchar();
    23     }
    24     while(isdigit(c)){
    25         t=(t<<3)+(t<<1)+c-'0';
    26         c=getchar();
    27     }
    28     return t*f;
    29 }
    30 const int maxn=6009;
    31 int n,m,_A,_B,a[maxn],b[maxn],c[5][5],d[maxn][maxn][3];
    32 char A[maxn],B[maxn];
    33 int f(char c){
    34     if(c=='A') return 1;
    35     if(c=='T') return 2;
    36     if(c=='G') return 3;
    37     return 4;
    38 }
    39 int main(){
    40     scanf("%s%s",A,B);n=strlen(A);m=strlen(B);
    41     rep(i,1,n) a[i]=f(A[i-1]);
    42     rep(i,1,m) b[i]=f(B[i-1]);
    43     rep(i,1,4)
    44         rep(j,1,4) c[i][j]=readint();
    45     _A=readint();_B=readint();_A=-_A;_B=-_B;
    46     rep(i,0,n)
    47         rep(j,0,m) 
    48             rep(k,0,2) d[i][j][k]=-inf;
    49     d[0][0][0]=0;
    50     rep(i,0,n){
    51         rep(j,0,m){
    52             rep(k,0,2) if(i>0&&j>0) d[i][j][0]=max(d[i][j][0],d[i-1][j-1][k]+c[a[i]][b[j]]);
    53             if(j){
    54                 d[i][j][1]=max(d[i][j][1],d[i][j-1][0]+_A);
    55                 d[i][j][1]=max(d[i][j][1],d[i][j-1][1]+_B);
    56                 d[i][j][1]=max(d[i][j][1],d[i][j-1][2]+_A);
    57             }
    58             if(i){
    59                 d[i][j][2]=max(d[i][j][2],d[i-1][j][0]+_A);
    60                 d[i][j][2]=max(d[i][j][2],d[i-1][j][2]+_B);
    61                 d[i][j][2]=max(d[i][j][2],d[i-1][j][1]+_A);
    62             }
    63         }
    64     }
    65     int ans=-inf;
    66     rep(i,0,2) ans=max(ans,d[n][m][i]);
    67     printf("%d
    ",ans);
    68     return 0;
    69 }
    View Code

     T4 并不难的DP...

     1 #include<cstdio> 
     2 #include<cstring>
     3 #include<cmath>
     4 #include<ctime>
     5 #include<iostream>
     6 #include<algorithm>
     7 #include<queue>
     8 #include<set>
     9 #define inf (0xffffffffll)
    10 #define l(a) ((a)<<1)
    11 #define r(a) ((a)<<1|1)
    12 #define b(a) (1<<(a))
    13 #define rep(i,a,b) for(int i=a;i<=(b);i++)
    14 #define clr(a) memset(a,0,sizeof(a))
    15 typedef long long ll;
    16 typedef unsigned long long ull;
    17 using namespace std;
    18 ll readll(){
    19     ll t=0,f=1;char c=getchar();
    20     while(!isdigit(c)){
    21         if(c=='-') f=-1;
    22         c=getchar();
    23     }
    24     while(isdigit(c)){
    25         t=(t<<3ll)+(t<<1ll)+ll(c-'0');
    26         c=getchar();
    27     }
    28     return ll(t*f);
    29 }
    30 const int maxm=1000009;
    31 ll n,m,d[maxm],a[maxm],q[maxm];
    32 struct node{
    33     ll p,w;
    34     inline bool operator<(const node A)const{
    35         return p<A.p;
    36     }
    37     inline void in(){
    38         p=readll();w=readll();
    39     }
    40 }x[maxm];
    41 int main(){
    42     //freopen("#input.txt","r",stdin);
    43     //freopen("#output.txt","w",stdout);
    44     n=readll();m=readll();
    45     rep(i,1,maxm-1) q[i]=-1;
    46     rep(i,1,m) x[i].in();sort(x+1,x+m+1);
    47     n=0;rep(i,1,m){
    48         if(x[i].p==x[i-1].p+1){
    49             q[++n]=x[i].w;
    50         }else if(x[i].p==x[i-1].p+2){
    51             n+=2;q[n]=x[i].w;
    52         }else{
    53             n+=3;q[n]=x[i].w;
    54         }
    55     } 
    56     d[0]=0;
    57     rep(i,1,n) if(q[i]!=-1){
    58         a[i]=a[i-1]^q[i];
    59         d[i]=d[i-1]+a[i];
    60     }else if(q[i+1]!=-1){
    61         int cnt=0;ll t1=inf,s1[32],t2=0,s2[32];
    62         clr(s1);clr(s2);
    63         for(int j=i+1;q[j]!=-1;j++,cnt++){
    64             t1^=q[j];
    65             rep(l,0,31) if((1ll<<l)&t1) s1[l]++;
    66         }
    67         for(int j=i+1;q[j]!=-1;j++){
    68             t2^=q[j];
    69             rep(l,0,31) if((1ll<<l)&t2) s2[l]++;
    70         }
    71         i+=cnt;
    72         d[i]=d[i-cnt-1];
    73         rep(j,0,31){
    74             t1=s1[j]+((a[i-cnt]^(1<<j))>>j);t2=s2[j]+((a[i-cnt]&(1<<j))>>j);
    75             if(t1>t2){
    76                 d[i]+=t2*(1ll<<j);a[i]+=t2&(1ll<<j);
    77             }else{
    78                 d[i]+=t1*(1ll<<j);a[i]+=t1&(1ll<<j);
    79             }
    80         }
    81     }else d[i]=d[i-1],a[i]=0;
    82     printf("%lld
    ",d[n]);
    83     //fclose(stdin);
    84     //fclose(stdout);
    85     return 0;
    86 }
    View Code
  • 相关阅读:
    司马光 王安石
    辛弃疾
    伯仲叔季
    三国时代
    西汉 东汉 三国(曹魏 蜀汉 东吴)
    数量关系练习题
    为什么不推荐使用外键约束
    Google Map API申请
    Android传感器——加速度传感器
    第三届空间信息智能服务研讨会
  • 原文地址:https://www.cnblogs.com/chensiang/p/7905462.html
Copyright © 2020-2023  润新知