結果
問題 | No.2189 六平方和 |
ユーザー |
![]() |
提出日時 | 2023-01-13 23:01:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 754 bytes |
コンパイル時間 | 1,574 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 71,424 KB |
最終ジャッジ日時 | 2024-12-24 19:02:27 |
合計ジャッジ時間 | 3,838 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
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)