結果
問題 | No.1255 ハイレーツ・オブ・ボリビアン |
ユーザー | trineutron |
提出日時 | 2020-10-09 23:00:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 653 bytes |
コンパイル時間 | 5,012 ms |
コンパイル使用メモリ | 206,356 KB |
実行使用メモリ | 8,200 KB |
最終ジャッジ日時 | 2023-09-27 19:14:44 |
合計ジャッジ時間 | 10,811 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 3 ms
4,376 KB |
testcase_03 | AC | 3 ms
4,376 KB |
testcase_04 | AC | 4 ms
4,380 KB |
testcase_05 | AC | 155 ms
5,376 KB |
testcase_06 | AC | 212 ms
5,572 KB |
testcase_07 | AC | 179 ms
5,372 KB |
testcase_08 | AC | 921 ms
6,504 KB |
testcase_09 | AC | 920 ms
5,920 KB |
testcase_10 | AC | 919 ms
5,888 KB |
testcase_11 | AC | 927 ms
7,716 KB |
testcase_12 | AC | 924 ms
7,844 KB |
testcase_13 | WA | - |
testcase_14 | AC | 1,953 ms
8,200 KB |
testcase_15 | AC | 902 ms
6,240 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int64_t solve(int64_t n) { constexpr int64_t sz = 50000; int64_t mod = 2 * n - 1; unordered_map<int64_t, int64_t> v; int64_t x = 1, m = 1; v[1] = 0; for (int i = 1; i <= sz; i++) { x = 2 * x % mod; m = n * m % mod; if (x == 1) return i; v[x] = i; } int64_t y = 1; for (int i = 1; ; i++) { y = y * m % mod; if (v[y]) { return sz * i + v[y]; } } } int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int64_t n; cin >> n; cout << solve(n) << endl; } }