題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2456
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #include <iostream> #include <cmath>
using namespace std;
bool is_square(int n){ if(n == 1) return true; int num = (int)sqrt(n); if(num * num == n) return true; return false; }
int main(){ int a, b; while(cin >> a >> b){ if(a == 0 && b == 0) break; int count = 0; for(int i=a; i<=b; ++i){ if(is_square(i)) count++; } cout << count << '\n'; } return 0; }
|