結果

問題 No.1312 Snake Eyes
ユーザー 0w1
提出日時 2020-12-18 12:15:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 413 bytes
コンパイル時間 1,943 ms
コンパイル使用メモリ 191,916 KB
最終ジャッジ日時 2025-01-17 02:52:34
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33 WA * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  ios::sync_with_stdio(false);

  int64_t N; { cin >> N; }

  for (int i = 2; (int64_t) i * i <= N; ++i) {
    int64_t n = N;
    int h = n % i;
    bool ok = true;
    for (; n; n /= i) ok &= h == n % i;
    if (ok) { cout << i << endl; return 0; }
    if (N % i == 0 && N / i < i - 1) { cout << i << endl; return 0; }
  }

  cout << N - 1 << endl;
}

0