标签:style blog http color io os ar strong for
Codeforces Round #267 (Div. 2)
(C和D的题解单独写:CF467C George and Job (DP) CF467D Fedor and Essay 建图DFS)
CF#267A
CF#267B
A
题意:给出宿舍各个寝室住了多少人、最多能住多少人,求有多少个寝室能住进这两个人……
代码:
1 //#pragma comment(linker, "/STACK:102400000,102400000") 2 #include<cstdio> 3 #include<cmath> 4 #include<iostream> 5 #include<cstring> 6 #include<algorithm> 7 #include<cmath> 8 #include<map> 9 #include<set> 10 #include<stack> 11 #include<queue> 12 using namespace std; 13 #define ll long long 14 #define usll unsigned ll 15 #define mz(array) memset(array, 0, sizeof(array)) 16 #define minf(array) memset(array, 0x3f, sizeof(array)) 17 #define REP(i,n) for(i=0;i<(n);i++) 18 #define FOR(i,x,n) for(i=(x);i<=(n);i++) 19 #define RD(x) scanf("%d",&x) 20 #define RD2(x,y) scanf("%d%d",&x,&y) 21 #define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z) 22 #define WN(x) printf("%d\n",x); 23 #define RE freopen("D.in","r",stdin) 24 #define WE freopen("1biao.out","w",stdout) 25 #define mp make_pair 26 #define pb push_back 27 const double eps=1e-10; 28 const double pi=acos(-1.0); 29 30 int main(){ 31 int n,x,y,ans=0; 32 RD(n); 33 while(n--){ 34 RD2(x,y); 35 if(y-x>=2)ans++; 36 } 37 WN(ans); 38 return 0; 39 }
B
题意:给出n,m,k,给出m+1个数a[i],代表m+1个人的那个什么情况,主角是第m+1个人。求a[i]和a[m+1]的n个二进制位中,有不超过k位不同的i有多少个(1<=i<=m)。
题解:直接暴力搞啊
代码:
1 //#pragma comment(linker, "/STACK:102400000,102400000") 2 #include<cstdio> 3 #include<cmath> 4 #include<iostream> 5 #include<cstring> 6 #include<algorithm> 7 #include<cmath> 8 #include<map> 9 #include<set> 10 #include<stack> 11 #include<queue> 12 using namespace std; 13 #define ll long long 14 #define usll unsigned ll 15 #define mz(array) memset(array, 0, sizeof(array)) 16 #define minf(array) memset(array, 0x3f, sizeof(array)) 17 #define REP(i,n) for(i=0;i<(n);i++) 18 #define FOR(i,x,n) for(i=(x);i<=(n);i++) 19 #define RD(x) scanf("%d",&x) 20 #define RD2(x,y) scanf("%d%d",&x,&y) 21 #define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z) 22 #define WN(x) printf("%d\n",x); 23 #define RE freopen("D.in","r",stdin) 24 #define WE freopen("1biao.out","w",stdout) 25 #define mp make_pair 26 #define pb push_back 27 const double eps=1e-10; 28 const double pi=acos(-1.0); 29 int a[1111]; 30 int n,m,k; 31 int main(){ 32 int i,j; 33 RD3(n,m,k); 34 REP(i,m+1){ 35 RD(a[i]); 36 } 37 int q=a[m]; 38 int ans=0; 39 REP(i,m){ 40 int t=q^a[i]; 41 int dif=0; 42 REP(j,n){ 43 if((t&1)==1)dif++; 44 t>>=1; 45 } 46 if(dif<=k)ans++; 47 } 48 WN(ans); 49 return 0; 50 }
标签:style blog http color io os ar strong for
原文地址:http://www.cnblogs.com/yuiffy/p/3980601.html