同构数
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i ++) {
int s = i, t = i * i;
bool flag = true;
while (s) {
if (s%10 != t%10) {
flag = false;
break;
}
s /= 10, t /= 10;
}
if (flag) cout << i << ' ';
}
return 0;
}
分解质因数
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int n;
cin >> n;
bool flag = true;
while (n != 1) {
for (int i = 2; i <= n; i ++) {
if (n%i == 0) {
if (flag) {
printf("%d=%d", n, i