結果
| 問題 | No.1312 Snake Eyes |
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2020-12-09 00:37:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 596 bytes |
| 記録 | |
| コンパイル時間 | 2,145 ms |
| コンパイル使用メモリ | 191,560 KB |
| 最終ジャッジ日時 | 2025-01-16 20:12:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 31 RE * 16 |
ソースコード
#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 powpow(ll x,ll n){
ll ans=1;
while(n){
if(n&1) ans=ans*x;
if(ans>1e12+1) return -1;
x=x*x;
n/=2;
}
return ans;
}
int main(){
int n;
cin>>n;
for(ll p=2;p<=100010;p++){
for(ll k=2;k<=41;k++){
ll tmp=powpow(p,k);
if(tmp==-1) continue;
ll t=(tmp-1)/(p-1);
if(t>n) break;
if(n%t!=0) continue;
if(n/t<p){
cout<<p<<endl;
return 0;
}
}
}
return 0;
}
umezo