結果
問題 | No.1312 Snake Eyes |
ユーザー |
![]() |
提出日時 | 2023-05-06 05:05:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,176 bytes |
コンパイル時間 | 3,815 ms |
コンパイル使用メモリ | 251,220 KB |
最終ジャッジ日時 | 2025-02-12 20:26:02 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 64 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;using ll=long long;using ld=long double;ld pie=3.141592653589793;ll inf=14449999999999999;ll mod=998244353;ll modpow(ll x, ll n) {if(n==0) return 1; //再帰の終了条件else if(n%2==1) {return (x*modpow(x, n-1)); //nが奇数ならnを1ずらす}else return modpow((x*x), n/2); //nが偶数ならnが半分になる}int main(){ll n;cin >> n;if (n==1){cout << 2 << endl;return 0;}else if (n==2){cout << 3 << endl;return 0;}ll ans=n-1;vector<ll>y(2000000,1);for (ll i = 0; i < y.size(); i++){y[i]+=i;}for (ll i = 2; i <=43; i++){bool ok=false;for (ll j = 2; j >=0; j++){y[j]+=modpow(j,i);if (y[j]>n){break;}if (n%y[j]==0&&n/y[j]<j){ok=true;ans=j;break;}}if (!ok){break;}}cout << ans << endl;}