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 |
超简单....留个足迹 但为什么上面就错了下面就对了 就改了一部分#include<iostream> using namespace std; int p; int main() { int times; int n,i; cin>>times; while(times--) { bool a[102]={0};//1表示开 0表示关 int m=0; cin>>p; for(i=1;i<=p;i++) { for(n=1;n*i<=p;n++) { if(a[n*i]==1)a[n*i]=0; if(a[n*i]==0)a[n*i]=1;//改这 cout<<a[n*i]<<endl; } } for(i=1;i<=p;i++) { if(a[i]==1) m++; } //cout<<m<<endl; } return 0; } #include<iostream> using namespace std; int p; int main() { int times; int n,i; cin>>times; while(times--) { bool a[102]={0};//1表示开 0表示关 int m=0; cin>>p; for(i=1;i<=p;i++) { for(n=1;n*i<=p;n++) { if(a[n*i]==1)a[n*i]=0; else a[n*i]=1; cout<<a[n*i]<<endl; } } for(i=1;i<=p;i++) { if(a[i]==1) m++; } //cout<<m<<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