-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path343c.cpp
More file actions
35 lines (33 loc) · 745 Bytes
/
343c.cpp
File metadata and controls
35 lines (33 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n + 1); i++)
typedef long long ll;
bool check_shinbunshi(ll n){
string t = to_string(n);
bool shinbunshi = true;
rep(i, t.size() / 2){
if (t[i] != t[t.size() -1 - i]){
shinbunshi = false;
break;
}
}
return shinbunshi;
}
bool check_factorial(ll n){
ll croot = cbrt(n);
return n == pow(croot,3);
}
int main(){
ll n;
cin >> n;
ll ans= -1;
for(ll i = n; i > 0; i--){
if(check_shinbunshi(i) && check_factorial(i)){
ans = i;
break;
}
}
cout << ans << endl;
return 0;
}