Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

还怕超时,没想到0ms,数据有多弱(用bitset,简洁一些)

Posted by KatrineYang at 2016-09-24 12:20:33 on Problem 1353
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator