Today the second time to do BC, not accustomed to HDU oj,ce 2 times ...
1002 Clarke and problem
#include <cstdio>#include<iostream>#include<string>#include<cstring>#include<queue>#include<vector>#include<stack>#include<vector>#include<map>#include<Set>#include<algorithm>using namespacestd;#definePB push_back#defineMP Make_pair#defineFi first#defineSe Second#defineCER (x) cout<< #x << ' = ' <<endltypedefLong Longll;Const intMAXN =1050;intdp[2][MAXN];//#define LOCALConst intMOD = 1e9+7;intMain () {#ifdef LOCAL freopen ("In.txt","R", stdin);#endif intT scanf"%d",&T); while(t--){ intN,p; scanf"%d%d",&n,&p); //Fill (dp[0],dp[0]+p,0);memset (dp[0],0,sizeof(dp[0])); dp[0][0] =1; for(inti =0; I < n; i++){ intc = i&1, NX = (i&1)^1; //Fill (dp[nx],dp[nx]+p,0);memcpy (Dp[nx],dp[c],sizeof(Dp[nx])); intA scanf"%d",&a); A%= p;if(a<0) A + = p;//g++ compiler negative number modulo or negative, here re a few times for(intj =0; J < P; J + +){ if(Dp[c][j]) {intt = (j+a)%p; Dp[nx][t]= (dp[nx][t]+ dp[c][j])%MOD; }}} printf ("%d\n",dp[n&1][0]); } return 0;}
View Code
1003 Clarke and Puzzle
Card time card too tight, according to the official solution 980ms over ... Change Memset to for,890ms.
Confidently wrote a two-dimensional line tree was stuck. Writing bit also encountered some strange errors.
#include <cstdio>#include<iostream>#include<string>#include<cstring>#include<queue>#include<vector>#include<stack>#include<vector>#include<map>#include<Set>#include<algorithm>using namespacestd;#definePB push_back#defineMP Make_pair#defineFi first#defineSe Second#defineCER (x) cout<< #x << ' = ' <<endltypedefLong Longll;Const intMAXN =505;intC[MAXN][MAXN],N,M,C[MAXN][MAXN];#defineLB (x) ((x) &-(x))intSumintXinty) { intR =0; for(intI=x;i>0; i-=lb (i))//For (; x>0; x-=lb (x)) strange mistake, written like this T for(intJ=y;j>0; j-=lb (j)) R^=C[i][j]; returnR;}voidAddintXintYintval) { for(inti=x;i<=n;i+=lb (i)) for(intj=y;j<=m;j+=lb (j)) C[I][J]^=Val;}//#define LOCALintMain () {#ifdef LOCAL freopen ("In.txt","R", stdin);#endif intT scanf"%d",&T); while(t--){ intQ scanf"%d%d%d",&n,&m,&q); //memset (c,0,sizeof (C)); for(inti =1; I <= N; i++){ //Fill (c[i]+1,c[i]+1+m,0); for(intj =1; J <= M; J + +) C[i][j] =0; } for(inti =1; I <= N; i++){ for(intj =1; J <= M; J + +) {scanf ("%d", c[i]+j); Add (I,j,c[i][j]); } } for(inti =0; i < Q; i++){ intOp scanf"%d",&op); if(OP = =1){ intX1,y1,x2,y2; scanf"%d%d%d%d",&x1,&y1,&x2,&y2); Puts (sum (x2,y2)^sum (x2,y1-1) ^sum (x1-1, y2) ^sum (x1-1, y1-1)?"Yes":"No"); }Else { intX,y,v; scanf"%d%d%d",&x,&y,&v); Add (X,y,c[x][y]^v); C[x][y]=v; } } } return 0;}
View Code
Bestcoder Round #56 1002 Clarke and Problem 1003 Clarke and puzzle