結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー 👑 NachiaNachia
提出日時 2020-10-09 22:38:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 171,684 KB
実行使用メモリ 5,268 KB
最終ジャッジ日時 2023-09-27 18:33:47
合計ジャッジ時間 6,358 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

#include<unordered_map>

LL loop(ULL N) {
	N = 2 * N - 1;
	unordered_map<ULL, ULL> X(40000);
	ULL p = 1;
	rep(i, 40000) { X[p] = i; p = p * 2 % N; if (p == 1) return i + 1; }
	p = 1;
	ULL q = 1; rep(i, 40000) q = q * (N / 2 + 1) % N;
	rep(i, 60000) {
		p = p * q % N;
		if (X.count(p)) return (i + 1) * 60000 + X[p];
	}
	return -1;
}

int main() {
	int T; cin >> T;
	while (T--) {
		ULL N; cin >> N;
		cout << loop(N) << endl;
	}

	return 0;
}
0