結果

問題 No.1312 Snake Eyes
ユーザー 👑 NachiaNachia
提出日時 2020-12-09 00:13:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 191,832 KB
最終ジャッジ日時 2025-01-16 20:06:14
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 83 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#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=2; 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;
}
0