結果
問題 |
No.1312 Snake Eyes
|
ユーザー |
|
提出日時 | 2020-12-09 00:29:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,226 bytes |
コンパイル時間 | 774 ms |
コンパイル使用メモリ | 92,236 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-18 22:18:53 |
合計ジャッジ時間 | 2,940 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 53 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <stdio.h> #include <queue> #include <deque> #include <cstdio> #include <set> #include <map> #include <bitset> #include <stack> #include <cctype> using namespace std; long long n; bool solve(long long x, long long y, long long z) { long long co = 0; long long now = 1; for (long long i = 0; i < z; i++) { co += now * y; if (100000000000000000 / now < x) { return true; } now *= x; } if (co >= n) { return true; } else { return false; } } int main() { cin >> n; long long ans = 1000000000000007; for (int i = 1; i <= 9; i++) { for (int j = 1; j < 40; j++) { long long l = i + 1, r = 2000000000000; while (r - l > 1) { long long mid = (l + r) / 2; if (solve(mid, i, j)) { r = mid; } else { l = mid; } } bool a = true; long long co = 0; long long now = 1; for (long long k = 0; k < j; k++) { co += now * i; if (100000000000000000 / now < r) { a = false; break; } now *= r; } if (co != n) { a = false; } if (a) { if (ans > r) { ans = r; } } } } cout << ans << endl; }