結果
| 問題 | 
                            No.1312 Snake Eyes
                             | 
                    
| コンテスト | |
| ユーザー | 
                             umezo
                         | 
                    
| 提出日時 | 2020-12-09 00:50:53 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 617 bytes | 
| コンパイル時間 | 2,078 ms | 
| コンパイル使用メモリ | 190,816 KB | 
| 最終ジャッジ日時 | 2025-01-16 20:17:55 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 51 WA * 10 RE * 24 | 
ソースコード
#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 n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x;
    if(ans-1>n*(ans-1)) return -1;
    x=x*x;
    n/=2;
  }
  return ans;
}
int main(){
  cin>>n;
  
  for(ll p=2;p<=100010;p++){
    for(ll k=1;k<=51;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;
      }
    }
  }
  cout<<n-1<<endl;
  return 0;
}
            
            
            
        
            
umezo