結果

問題 No.1312 Snake Eyes
ユーザー DaYuanChi
提出日時 2021-01-22 01:04:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 463 bytes
コンパイル時間 1,723 ms
コンパイル使用メモリ 165,648 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-12-25 15:21:44
合計ジャッジ時間 32,137 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43 WA * 33 TLE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool f(ll n, ll p){
  bool flag = true;
  int a = n%p;
  ll pow = p;
  while(n/pow>0){
    int b = (n/pow)%p;
    if(b!=a){
      flag = false;
      break;
    }
    pow *= p;
  }
  return flag;
}

int main(){
  ll n; cin >> n;
  ll ans = 0;
  for(int i = 2; i*i <= n; i++){
    if(f(n, i)){
      ans = i;
      break;
    }
  }
  if(ans==0) ans = n-1;
  cout << ans << endl;
  return 0;
}
 
0