結果
問題 |
No.1255 ハイレーツ・オブ・ボリビアン
|
ユーザー |
![]() |
提出日時 | 2020-10-09 23:00:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 653 bytes |
コンパイル時間 | 2,017 ms |
コンパイル使用メモリ | 200,392 KB |
最終ジャッジ日時 | 2025-01-15 05:39:16 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 WA * 1 |
ソースコード
#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; } }