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 |
打印1-8192的情况,当“人数=糖数=n^2”,每个人刚好能够分一粒糖。# 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator