結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 265 ms
6,480 KB
testcase_06 AC 349 ms
6,468 KB
testcase_07 AC 301 ms
6,468 KB
testcase_08 AC 1,589 ms
8,484 KB
testcase_09 AC 1,578 ms
7,808 KB
testcase_10 AC 1,536 ms
7,896 KB
testcase_11 AC 1,608 ms
8,936 KB
testcase_12 AC 1,625 ms
8,812 KB
testcase_13 WA -
testcase_14 TLE -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int solve(int n) {
    constexpr int64_t sz = 50000;
    int64_t mod = 2 * n - 1;
    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