| ||||||||||
| 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:到底每次做完之后q应在哪个地方清0呀????????In Reply To:到底每次做完之后q应在哪个地方清0呀???????? Posted by:00430030 at 2004-12-30 10:24:52 #include<stdio.h>
#include<malloc.h>
void main(){
int m,n,i,j,k;
int *per;
scanf("%d",&m);
for(k=0;k<m;k++){
scanf("%d",&n);
per=(int*)malloc((n+1)*sizeof(int));
for(i=1;i<=n;i++){
per[i]=0;
}
for(i=1;i<=n;i++){
for(j=i;j<=n;j+=i){
if(per[j]==0) per[j]=1;
else per[j]=0;
}
}
j=0;
for(i=1;i<=n;i++){
if(per[i]==1) j++;
}
printf("%d\n",j);
free(per);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator