結果

問題 No.2189 六平方和
ユーザー rlangevinrlangevin
提出日時 2023-01-13 23:01:55
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 84,016 KB
最終ジャッジ日時 2023-08-26 04:46:01
合計ジャッジ時間 4,783 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
83,508 KB
testcase_01 AC 89 ms
83,336 KB
testcase_02 AC 89 ms
83,604 KB
testcase_03 AC 90 ms
83,696 KB
testcase_04 AC 88 ms
83,444 KB
testcase_05 AC 88 ms
83,652 KB
testcase_06 AC 88 ms
83,584 KB
testcase_07 AC 89 ms
83,804 KB
testcase_08 AC 89 ms
83,340 KB
testcase_09 AC 88 ms
83,548 KB
testcase_10 AC 89 ms
83,556 KB
testcase_11 AC 91 ms
83,912 KB
testcase_12 AC 87 ms
83,432 KB
testcase_13 AC 89 ms
83,540 KB
testcase_14 AC 89 ms
83,332 KB
testcase_15 AC 89 ms
83,572 KB
testcase_16 AC 90 ms
83,580 KB
testcase_17 AC 90 ms
83,504 KB
testcase_18 AC 90 ms
83,568 KB
testcase_19 AC 89 ms
83,560 KB
testcase_20 AC 93 ms
83,552 KB
testcase_21 AC 95 ms
83,976 KB
testcase_22 AC 90 ms
83,560 KB
testcase_23 AC 94 ms
83,988 KB
testcase_24 AC 94 ms
84,016 KB
testcase_25 AC 91 ms
83,992 KB
testcase_26 AC 90 ms
83,336 KB
testcase_27 AC 90 ms
83,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

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

i = 0
S = set()
A = pow(M, N, B)
D = dict()
while i * i < 10 ** 9:
    S.add(i * i)
    D[i * i] = i
    i += 1
L = sorted(list(S))
ind = bisect_right(L, A)
ans = [D[L[ind-1]]]
A -= L[ind-1]
ind = bisect_right(L, A)
ans.append(D[L[ind-1]])
A -= L[ind-1]
LL = []
for a in L:
    if a <= A:
        LL.append(a)
N = len(LL)
for a in range(N):
    for b in range(a, N):
        for c in range(b, N):
            for d in range(c, N):
                if LL[a] + LL[b] + LL[c] + LL[d] == A:
                    ans.append(D[LL[a]])
                    ans.append(D[LL[b]])
                    ans.append(D[LL[c]])
                    ans.append(D[LL[d]])
print("YES")
print(*ans)
                    
0