'commit'
This commit is contained in:
25
TangDou/LanQiaoBei/LanQiao14GuoSai/1_2.cpp
Normal file
25
TangDou/LanQiaoBei/LanQiao14GuoSai/1_2.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
bool is_octal_palindrome(int n) {
|
||||
string s1 = "";
|
||||
while (n) {
|
||||
s1 += to_string(n % 8);
|
||||
n /= 8;
|
||||
}
|
||||
string s2 = s1;
|
||||
reverse(s2.begin(), s2.end());
|
||||
return s1 == s2;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
int s = (int)sqrt(n);
|
||||
for (int i = 1; i <= s; i++) {
|
||||
int s2 = i * i;
|
||||
if (is_octal_palindrome(s2)) cout << s2 << " ";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user