結果

問題 No.1312 Snake Eyes
ユーザー trineutron
提出日時 2020-12-09 07:59:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 422 bytes
コンパイル時間 2,014 ms
コンパイル使用メモリ 191,340 KB
最終ジャッジ日時 2025-01-16 20:38:28
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int64_t n;
    cin >> n;
    if (n <= 2) {
        cout << n + 1 << endl;
        return 0;
    }
    for (int64_t p = 2; p * p <= n; p++) {
        int64_t s = 1;
        while (s * p + 1 <= n) {
            s = s * p + 1;
        }
        if (n % s == 0) {
            cout << p << endl;
            return 0;
        }
    }
    cout << n - 1 << endl;
}
0