UVA 11461

题目链接

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <string>
 4 #include <cmath>
 5 #include <ctime>
 6 #include <cstdlib>
 7 #include <iostream>
 8 using namespace std;
 9 #define LL long long
10 #define MOD 1000000007
11 int p[1001];
12 int judge(int x)
13 {
14     int str,end,mid;
15     if(x <= 0)
16     return 0;
17     str = 1;
18     end = 1000;
19     while(str < end)
20     {
21         mid = (str + end + 1)/2;
22         if(p[mid] > x)
23         end = mid - 1;
24         else
25         str = mid;
26     }
27     return end;
28 }
29 int main()
30 {
31     int x,y,i;
32     for(i = 1;i <= 1000;i ++)
33     p[i] = i*i;
34     while(scanf("%d%d",&x,&y)!=EOF)
35     {
36         if(x == 0&&y == 0) break;
37         printf("%d
",judge(y)-judge(x-1));
38     }
39     return 0;
40 }

原文地址:https://www.cnblogs.com/naix-x/p/3382725.html