标签:style class blog c code tar
简单数论题。区间减法。
1 //Accepted 0 KB 9 ms 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 const int MAXN = 100005; 6 int f[MAXN]; 7 void pre() 8 { 9 for (int i=1;i*i<MAXN;i++) 10 { 11 f[i*i]=1; 12 } 13 f[0]=0; 14 for (int i=1;i<MAXN;i++) 15 { 16 f[i]+=f[i-1]; 17 } 18 } 19 int a,b; 20 void slove() 21 { 22 printf("%d\n",f[b]-f[a-1]); 23 } 24 int main() 25 { 26 pre(); 27 while (scanf("%d%d",&a,&b),a+b) 28 { 29 slove(); 30 } 31 return 0; 32 }
uva11461Square Numbers,布布扣,bubuko.com
标签:style class blog c code tar
原文地址:http://www.cnblogs.com/djingjing/p/3749274.html