Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
还怕超时,没想到0ms,数据有多弱(用bitset,简洁一些)#include <stdio.h> #include <bitset> using namespace std; int n,m,k; char f; int main() { while(1){ scanf("%d", &n); if(!(~n)) return 0; bitset<130> c; bitset<130> a; for(int i = 0; i < n; i++) a.set(i); scanf("%c%d%c%d", &f, &m, &f, &k); for(int i = 0; i < m; i++) c.set(i); for(int i = 0; i < k; i++){ bool l = c.test(n-1); bitset<130> t = c<<1; if(l) t.set(0); c = c ^ t; } c = c & a; printf("%d,%d,%d: %d\n", n,m,k,c.count()); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator