結果
| 問題 |
No.1312 Snake Eyes
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2020-12-09 08:08:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 571 bytes |
| コンパイル時間 | 2,119 ms |
| コンパイル使用メモリ | 193,192 KB |
| 最終ジャッジ日時 | 2025-01-16 20:38:41 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 81 WA * 4 |
ソースコード
#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;
}
}
int64_t ans = n - 1;
for (int64_t d = 1; (d + 1) * (d + 1) <= n; d++) {
if (n % d == 0) {
ans = n / d - 1;
}
}
cout << ans << endl;
}
trineutron