結果

問題 No.2189 六平方和
ユーザー shobonvipshobonvip
提出日時 2023-01-13 22:31:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 76,544 KB
最終ジャッジ日時 2023-08-26 04:14:41
合計ジャッジ時間 3,926 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,896 KB
testcase_01 AC 79 ms
72,016 KB
testcase_02 AC 74 ms
72,108 KB
testcase_03 AC 74 ms
71,820 KB
testcase_04 AC 77 ms
72,100 KB
testcase_05 AC 75 ms
72,328 KB
testcase_06 AC 76 ms
72,236 KB
testcase_07 AC 73 ms
72,016 KB
testcase_08 AC 76 ms
72,100 KB
testcase_09 AC 75 ms
72,016 KB
testcase_10 AC 74 ms
71,888 KB
testcase_11 AC 78 ms
76,516 KB
testcase_12 AC 78 ms
76,544 KB
testcase_13 AC 79 ms
72,220 KB
testcase_14 AC 78 ms
72,092 KB
testcase_15 AC 75 ms
71,908 KB
testcase_16 AC 77 ms
71,868 KB
testcase_17 AC 75 ms
72,184 KB
testcase_18 AC 78 ms
72,284 KB
testcase_19 AC 81 ms
76,456 KB
testcase_20 AC 78 ms
76,396 KB
testcase_21 AC 80 ms
76,488 KB
testcase_22 AC 82 ms
76,148 KB
testcase_23 AC 82 ms
76,148 KB
testcase_24 AC 79 ms
76,532 KB
testcase_25 AC 82 ms
76,520 KB
testcase_26 AC 83 ms
76,284 KB
testcase_27 AC 82 ms
76,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
n, m, b = map(int,input().split())
f = pow(m, n, b)
while True:
	k = random.randrange(b)
	targ = (f - k * k) % b
	g = [k]
	for j in range(5):
		i = 0
		while True:
			if (i + 1) ** 2 > targ:
				break
			i += 1
		targ = targ - i * i
		g.append(i)

	v = 0
	for i in range(6):
		v += g[i] * g[i]
		if g[i] == 0:
			g[i] += b
	if v % b != pow(m, n, b):
		continue
	break

#print(targ)
print("YES")
print(*g)
0