code+11月月赛

Posted ChenThree

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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\n",ans);
68     return 0;
69 }
View Code

 

以上是关于code+11月月赛的主要内容,如果未能解决你的问题,请参考以下文章

11月月赛

洛谷11月月赛round.1

洛咕11月月赛部分题解 By cellur925

csu-2018年11月月赛Round2-div1题解

csu-2018年11月月赛Round2-div2题解

Luogu 9月月赛A(BSGS)