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 |
Re:帮你改了一下,提交结果WA,你再看看,是不是没有筛选好。把原来的筛选的外循环1001改成1000002就对了。In Reply To:帮你改了一下,提交结果WA,你再看看,是不是没有筛选好。 Posted by:bjss222 at 2007-07-28 01:17:21 > > > > #include <iostream> > #include <cmath> > using namespace std; > const int N=1000002; > struct array{ > bool disp; > unsigned int value; > }; > array a[N]; > > int main(void){ > __int64 i,j,index; > int count,H; > > for(i=5;i<1000002;i+=4){ a[i].value=0; a[i].disp=false; } > > for(i=5;i<1000002;i+=4){ > for(j=5,index=i*j;index<1000002,j<(1000002/i)+1;j+=4){ > index=i*j; > if(a[i].value==0 && !a[i].disp) a[index].value=1; > else{ a[index].value=0; a[index].disp=true; } > } > } > > count=0; for(i=25;i<N;i+=4){ if(a[i].value) count++; a[i].value=count; } > > while(cin>>H,H){ cout<<H<<" "<<a[H].value<<endl;} > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator