Files
python/TangDou/ShuLun/SL1.cpp

30 lines
493 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
//是不是同构数
bool isTongGou(int n) {
int a = n * n;
bool res = true;
while (n) {
int b = n % 10;
n /= 10;
int c = a % 10;
a /= 10;
if (b != c) {
res = false;
break;
}
}
return res;
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++)
if (isTongGou(i)) cout << i << " ";
return 0;
}