Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <cctype>
- #include <climits>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <list>
- #include <map>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <string>
- #include <vector>
- #define inf 1000000000
- #define MAXN 100000
- using namespace std;
- bool is_palindrome(long long x) {
- long long tmp_x = x;
- long long x_reversed = 0;
- while (tmp_x) {
- int digit = tmp_x%10;
- x_reversed = x_reversed*10 + digit;
- tmp_x/=10;
- }
- return x == x_reversed;
- }
- long long next_palindrome(long long x) {
- ++x;
- while (!is_palindrome(x)) {
- ++x;
- }
- return x;
- }
- int main()
- {
- int t;
- scanf("%d\n", &t);
- for (int qwertz = 0; qwertz < t; ++qwertz) {
- long long a, b;
- scanf("%lld%lld", &a, &b);
- long long hi = sqrt(b);
- for (long long i = 1; i <= hi; i = next_palindrome(i)) {
- if (is_palindrome(i*i)) {
- printf("fair number:%lld root:%lld\n", i*i, i);
- }
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement