結果
問題 |
No.1312 Snake Eyes
|
ユーザー |
![]() |
提出日時 | 2020-12-09 01:44:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 777 bytes |
コンパイル時間 | 2,068 ms |
コンパイル使用メモリ | 192,148 KB |
最終ジャッジ日時 | 2025-01-16 20:26:47 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 66 WA * 19 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; ll n; ll powpow(ll x,ll m){ ll y=x; ll ans=1; while(m){ if(m&1){ if(log10(ans)+log10(x)>18) return -1; ans=ans*x; } m/=2; if(m!=0 && x>1e9) return -1; x=x*x; } return ans; } int main(){ cin>>n; if(n==1){ cout<<2<<endl; return 0; } if(n==2){ cout<<3<<endl; return 0; } for(ll p=2;p<=1000010;p++){ for(ll k=2;k<41;k++){ ll tmp=powpow(p,k); if(tmp==-1) break; ll t=(tmp-1)/(p-1); if(t>n) break; if(n%t!=0) continue; if(n/t<p){ cout<<p<<endl; return 0; } } } cout<<n-1<<endl; return 0; }