結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 107 ms
4,816 KB
testcase_06 AC 132 ms
4,624 KB
testcase_07 AC 112 ms
4,964 KB
testcase_08 AC 507 ms
4,900 KB
testcase_09 AC 512 ms
5,096 KB
testcase_10 AC 506 ms
4,856 KB
testcase_11 AC 515 ms
4,860 KB
testcase_12 AC 505 ms
4,852 KB
testcase_13 WA -
testcase_14 AC 793 ms
4,996 KB
testcase_15 AC 500 ms
5,160 KB
権限があれば一括ダウンロードができます

ソースコード

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) * 40000 + X[p];
	}
	return -1;
}

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

	return 0;
}
0