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

打印1-8192的情况,当“人数=糖数=n^2”,每个人刚好能够分一粒糖。

Posted by gzw_02 at 2008-07-08 16:55:04 on Problem 3372 and last updated at 2008-07-08 16:58:00
# include <algorithm>
# include <iostream>
using namespace std;
const unsigned L=8192;
const unsigned M=8192;
bool use[L]; 
int sum[M];
int main(){
        int i,n,p;
		sum[0]=0;
        for(i=1;i<M;i++){
        sum[i]=sum[i-1]+i; 
		}
		for(n=0;n<L;n++){
	 
        memset(use,0,sizeof(bool)*(n+1));
		for(i=0;i<M;i++){
			   use[sum[i]%(n+1)]=true;
		}
		   for(i=0;i<n+1;i++) 
			   if(use[i]==false) break;
		   if(i>n) cout<<n+1<<endl;
		}
	 
	  	return 1;
}


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