poj 1218(模拟)
作者:互联网
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main(){ int n,p; int i,j; scanf("%d",&n); bool data[101]; for(i=3;i<=100;i++){ for(j=i;j<=100;j+=i){ data[j] = !data[j]; } } while(n--){ int ans = 0; scanf("%d",&p); memset(data,true,sizeof(data)); for(i=2;i<=p;i+=2){ data[i] = !data[i]; } for(i=3;i<=p;i++){ for(j=i;j<=p;j+=i){ data[j] = !data[j]; } } for(i=1;i<=p;i++){ if(data[i])ans++; } printf("%d\n",ans); } return 0; }
标签:std,main,int,1218,poj,bool,include,模拟 来源: https://www.cnblogs.com/stevenzrx/p/15073140.html