結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー anagohirameanagohirame
提出日時 2020-10-09 23:52:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 560 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 76,392 KB
最終ジャッジ日時 2023-09-27 20:12:37
合計ジャッジ時間 3,140 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,264 KB
testcase_01 AC 69 ms
71,004 KB
testcase_02 AC 75 ms
75,692 KB
testcase_03 AC 76 ms
75,248 KB
testcase_04 AC 79 ms
75,480 KB
testcase_05 AC 79 ms
76,240 KB
testcase_06 AC 82 ms
76,088 KB
testcase_07 AC 80 ms
76,328 KB
testcase_08 AC 173 ms
76,084 KB
testcase_09 AC 171 ms
76,124 KB
testcase_10 AC 174 ms
76,032 KB
testcase_11 AC 170 ms
76,188 KB
testcase_12 AC 176 ms
75,992 KB
testcase_13 WA -
testcase_14 AC 211 ms
76,024 KB
testcase_15 AC 172 ms
76,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

def phi(x):
	prime = []
	i = 2
	y = x
	while i*i <= x:
		if y%i == 0:
			prime.append(i)
			while y%i == 0:
				y //= i
		i += 1

	if y > 1:
		prime.append(y)
	res = x
	for p in prime:
		res = res * (p-1) // p

	div = []
	i = 1
	while i * i <= res:
		if res % i == 0:
			div.append(i)
			div.append(res // i)
		i += 1
	return div

for _ in range(int(input())):
	n = int(input()) * 2
	div = phi(n-1)
	#print(div)
	ans = n
	for d in div:
		if pow(2, d, n-1) == 1:
			ans = min(ans, d)
	print(ans)
0