結果
| 問題 |
No.1312 Snake Eyes
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2020-12-09 00:14:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 425 bytes |
| コンパイル時間 | 2,058 ms |
| コンパイル使用メモリ | 191,576 KB |
| 最終ジャッジ日時 | 2025-01-16 20:07:04 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 85 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
LL N; cin>>N;
LL ans=N+1;
for(LL i=1; i*i<=N; i++){ if(N%i==0) if((N/i-1)>i) ans=min(ans,N/i-1); }
for(LL i=2; i*i<=N; i++){
LL x=1; while(x*i+1<=N) x=x*i+1;
if(N%x!=0) continue;
if(N/x>=i) continue;
ans=min(ans,i);
}
cout<<ans<<endl;
return 0;
}
Nachia