Codeforces 984a
1#include <bits/stdc++.h>2 using namespacestd;3 intN;4 intnum[1010];5 intMain () {6scanf"%d",&n);7 for(intI=1; i<=n;i++) scanf ("%d",&num[i]);8Sort (num+1, num+n+1);9 if(n%2==1) printf ("%d", num[(n+1)/2]);Ten Elseprintf"%d", num[n/2]); One return 0; A}
View Code
Codeforces 984b
1#include <bits/stdc++.h>2 using namespacestd;3 intn,m;4 Charsz[ the][ the];5 intdivs[8][2]={{0,1},{0,-1},{1,0},{-1,0},{-1,-1},{1,-1},{-1,1},{1,1}};6 intMain () {7 while(SCANF ("%d%d", &n,&m)! =EOF) {8 for(intI=1; i<=n;i++) scanf ("%s", sz[i]+1);9 for(intI=1; i<=n;i++){Ten for(intj=1; j<=m;j++){ One if(sz[i][j]=='*')Continue; A Else if(sz[i][j]=='.'){ - for(intk=0;k<8; k++){ - intx=i+divs[k][0],y=j+divs[k][1]; the if(x>=1&&x<=n&&y>=1&&y<=m) { - if(sz[x][y]=='*') {printf ("no\n");return 0;} - } - } +}Else{ - intnum=sz[i][j]-'0'; + for(intk=0;k<8; k++){ A intx=i+divs[k][0],y=j+divs[k][1]; at if(x>=1&&x<=n&&y>=1&&y<=m) { - if(sz[x][y]=='*') {num--;} - } - } - if(num!=0) {printf ("no\n");return 0;} - } in //if (i==n&&j==m) printf ("sbsbsbsb\n"); - } to } + //printf ("sbbsbsbsbsb\n"); -printf"yes\n"); the } * return 0; $}
View Code
Skip the C question and fill in the D question first.
CODEFORCES984D first post the link: Read someone else's code: 80335949
1#include <bits/stdc++.h>2 using namespacestd;3 intn,q;4 intnum[5010];5 intdp[5010][5010],f[5010][5010];6 intMain () {7scanf"%d",&n);8 for(intI=1; i<=n;i++){9scanf"%d",&num[i]);Tendp[i][i]=f[i][i]=Num[i]; One } A for(intj=2; j<=n;j++){ - for(inti=j-1; i>=1; i--){ -f[i][j]=f[i][j-1]^f[i+1][j]; theDp[i][j]=max (F[i][j],max (dp[i][j-1],dp[i+1][j])); - } - } -scanf"%d",&q); + while(q--){ - intL,r; +scanf"%d%d",&l,&R); Acout<<dp[l][r]<<Endl; at } - return 0; -}
View Code
Codeforces C or stick a link to someone else 80331434
1#include <bits/stdc++.h>2 using namespacestd;3typedefLong LongLL;4 intN;5 LL p,q,c;6 7 ll gcd (ll A,ll b) {8 if(b==0)returnA;9 Else returnGCD (b,a%b);Ten } One A intMain () { -scanf"%d",&n); - while(n--){ thescanf"%lld%lld%lld",&p,&q,&c); - //printf ("%d\n", gcd (P,q)); -q=q/gcd (p,q); - //printf ("%d\n", q); + while(GCD (q,c)! =1){ -LL tmp=gcd (q,c); + while(q%tmp==0) q=q/tmp; A } at if(q==1) printf ("finite\n"); - Elseprintf"infinite\n"); - } - return 0; -}
View Code
Codeforces 984 Supplementary Questions