結果
問題 | No.800 四平方定理 |
ユーザー | 👑 H20 |
提出日時 | 2020-11-19 09:44:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 544 bytes |
コンパイル時間 | 1,708 ms |
コンパイル使用メモリ | 86,752 KB |
実行使用メモリ | 285,056 KB |
最終ジャッジ日時 | 2023-09-30 15:44:51 |
合計ジャッジ時間 | 6,774 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 163 ms
90,564 KB |
testcase_01 | AC | 215 ms
96,476 KB |
testcase_02 | AC | 182 ms
89,980 KB |
testcase_03 | AC | 193 ms
92,216 KB |
testcase_04 | AC | 181 ms
89,192 KB |
testcase_05 | AC | 189 ms
91,640 KB |
testcase_06 | AC | 235 ms
101,088 KB |
testcase_07 | AC | 211 ms
94,400 KB |
testcase_08 | AC | 229 ms
100,956 KB |
testcase_09 | AC | 219 ms
97,028 KB |
testcase_10 | TLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
import collections N,D=map(int, input().split()) Square = [] P = [] M = [] for i in range(N+1): Square.append(i**2) for i in range(1,N+1): for j in range(1,N+1): P.append(Square[i]+Square[j]) M.append(Square[i]-Square[j]) P=collections.Counter(P) M=collections.Counter(M) P = sorted( P.items() ) M = sorted( M.items() ) j = len(M)-1 ans = 0 mk,mv=M[j] for pk, pv in P: while mk+pk > D and j>=0: j-=1 mk,mv=M[j] if mk+pk==D: ans += mv*pv j-=1 mk,mv=M[j] print(ans)