标签:程序 problems bottom cte 进制 ble span esc log
1 #include<stdio.h> 2 #define N 1000005 3 int a[1000005]={0}; 4 int b[1000005],i; 5 void dabiao() //素数打表 6 { 7 int j; 8 a[0]=a[1]=1; //把前两个赋值0,其余赋值1怎么不对??? 9 10 for(i=2;i<N;i++) 11 if(!a[i]) 12 {for(j=i+i;j<N;j+=i) 13 a[j]=1; 14 15 } 16 17 } 18 void biao() //又一个表..不太明白是打表吗 19 { 20 int t=0; 21 for(i=0;i<N;i++) 22 {if(!a[i]) 23 {int k,sum; 24 k=i; 25 sum=0; 26 27 while(k!=0) 28 {sum+=k%10; 29 k=k/10; 30 31 } 32 if(!a[sum]) 33 t++; 34 35 36 37 38 } 39 b[i]=t; 40 41 } 42 43 } 44 int main() 45 { 46 dabiao(); 47 biao(); 48 int T,L,R; 49 int i=1,s; 50 scanf("%d",&T); 51 while(T--) 52 { 53 scanf("%d%d",&L,&R); 54 s=b[R]-b[L-1]; 55 printf("Case #%d: %d\n",i++,s); 56 57 58 } 59 return 0; 60 }
标签:程序 problems bottom cte 进制 ble span esc log
原文地址:http://www.cnblogs.com/hss-521/p/7242367.html