結果

問題 No.2189 六平方和
ユーザー testestesttestestest
提出日時 2022-12-16 00:12:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 71,700 KB
最終ジャッジ日時 2023-08-17 20:35:21
合計ジャッジ時間 4,097 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,696 KB
testcase_01 AC 73 ms
71,228 KB
testcase_02 AC 72 ms
71,444 KB
testcase_03 AC 76 ms
71,116 KB
testcase_04 AC 76 ms
71,388 KB
testcase_05 AC 75 ms
71,244 KB
testcase_06 AC 75 ms
71,400 KB
testcase_07 AC 75 ms
71,336 KB
testcase_08 AC 75 ms
71,276 KB
testcase_09 AC 75 ms
71,640 KB
testcase_10 AC 72 ms
71,412 KB
testcase_11 AC 72 ms
71,636 KB
testcase_12 AC 72 ms
71,276 KB
testcase_13 AC 73 ms
71,700 KB
testcase_14 AC 74 ms
71,556 KB
testcase_15 AC 76 ms
71,264 KB
testcase_16 AC 75 ms
71,672 KB
testcase_17 AC 73 ms
71,404 KB
testcase_18 AC 71 ms
71,360 KB
testcase_19 AC 75 ms
71,664 KB
testcase_20 AC 75 ms
71,448 KB
testcase_21 AC 76 ms
71,460 KB
testcase_22 AC 75 ms
71,260 KB
testcase_23 AC 77 ms
71,332 KB
testcase_24 AC 75 ms
71,272 KB
testcase_25 AC 72 ms
71,604 KB
testcase_26 AC 72 ms
71,276 KB
testcase_27 AC 75 ms
71,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def f(N):
	# Nを4平方和で表す O(N^1.5)
	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+2*c*c>N: break
				dd=N-a*a-b*b-c*c
				d=math.isqrt(dd)
				if d*d==dd: return (a,b,c,d)


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

X=pow(M,N,B)
a=math.isqrt(X)
X-=a*a
b=math.isqrt(X)
X-=b*b
print(*f(X),a,b)
0