結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー trineutrontrineutron
提出日時 2020-10-09 22:56:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 1,927 ms
コンパイル使用メモリ 206,904 KB
実行使用メモリ 8,312 KB
最終ジャッジ日時 2023-09-27 19:04:35
合計ジャッジ時間 11,109 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,384 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 155 ms
5,600 KB
testcase_06 AC 200 ms
5,600 KB
testcase_07 AC 163 ms
5,376 KB
testcase_08 AC 829 ms
6,308 KB
testcase_09 AC 837 ms
5,888 KB
testcase_10 AC 829 ms
6,096 KB
testcase_11 AC 846 ms
7,816 KB
testcase_12 AC 929 ms
7,924 KB
testcase_13 WA -
testcase_14 AC 1,940 ms
8,312 KB
testcase_15 AC 905 ms
5,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int solve(int n) {
    constexpr int64_t sz = 50000;
    int64_t mod = 2 * n - 1;
    unordered_map<int64_t, int> v;
    int64_t x = 1, m = 1;
    v[1] = 0;
    for (int i = 1; i <= sz; i++) {
        x = 2 * x % mod;
        m = (mod + 1) / 2 * 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];
        }
    }
    return -1;
}

int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        int n;
        cin >> n;
        cout << solve(n) << endl;
    }
}
0