結果

問題 No.2189 六平方和
ユーザー testestesttestestest
提出日時 2022-12-15 23:42:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 645 bytes
コンパイル時間 1,360 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 75,664 KB
最終ジャッジ日時 2023-08-17 19:30:41
合計ジャッジ時間 9,642 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
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 -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(N):
	# Nを4平方和で表す O(N^2)
	for a in range(N+1):
		if 4*a*a>N: break
		for b in range(a,N+1):
			if a*a+3*b*b>N: break
			for c in range(b,N+1):
				if a*a+b*b+c*c>N: break
				for d in range(c,N+1):
					v=a*a+b*b+c*c+d*d
					if v>N: break
					if v==N: return (a,b,c,d)

def mul(p,q,M):
	return (
		(p[0]*q[0]+p[1]*q[1]+p[2]*q[2]+p[3]*q[3])%M,
		(p[0]*q[1]-p[1]*q[0]+p[2]*q[3]-p[3]*q[2])%M,
		(p[0]*q[2]-p[1]*q[3]-p[2]*q[0]+p[3]*q[1])%M,
		(p[0]*q[3]+p[1]*q[2]-p[2]*q[1]-p[3]*q[0])%M,
	)

N,M,B=map(int,input().split())

b=f(M)
ans=(0,0,0,1)
while N:
	if N%2:
		ans=mul(ans,b,B)
	b=mul(b,b,B)
	N//=2

print("Yes")
print(*ans)
0