結果

問題 No.800 四平方定理
ユーザー Coki628Coki628
提出日時 2020-08-20 10:42:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,931 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 275,768 KB
最終ジャッジ日時 2024-04-21 05:30:32
合計ジャッジ時間 22,572 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
69,120 KB
testcase_01 AC 70 ms
72,832 KB
testcase_02 AC 66 ms
70,400 KB
testcase_03 AC 66 ms
71,040 KB
testcase_04 AC 67 ms
70,144 KB
testcase_05 AC 72 ms
71,168 KB
testcase_06 AC 74 ms
75,264 KB
testcase_07 AC 71 ms
71,808 KB
testcase_08 AC 68 ms
72,704 KB
testcase_09 AC 73 ms
73,344 KB
testcase_10 AC 790 ms
207,704 KB
testcase_11 AC 841 ms
202,776 KB
testcase_12 AC 861 ms
202,888 KB
testcase_13 AC 835 ms
202,792 KB
testcase_14 AC 869 ms
202,652 KB
testcase_15 AC 869 ms
202,792 KB
testcase_16 AC 880 ms
202,828 KB
testcase_17 AC 876 ms
202,668 KB
testcase_18 AC 863 ms
203,016 KB
testcase_19 AC 851 ms
202,948 KB
testcase_20 AC 45 ms
53,828 KB
testcase_21 AC 44 ms
54,272 KB
testcase_22 AC 901 ms
202,932 KB
testcase_23 AC 1,876 ms
275,768 KB
testcase_24 AC 1,838 ms
275,252 KB
testcase_25 AC 1,931 ms
275,372 KB
testcase_26 AC 61 ms
53,748 KB
testcase_27 AC 43 ms
53,888 KB
testcase_28 AC 1,759 ms
275,620 KB
testcase_29 AC 1,778 ms
275,504 KB
testcase_30 AC 1,812 ms
275,624 KB
testcase_31 AC 1,580 ms
275,440 KB
testcase_32 AC 1,818 ms
275,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N, D = MAP()

C = Counter()
for z in range(1, N+1):
    zz = z**2
    for w in range(1, N+1):
        ww = w**2
        C[zz-ww] += 1

NN = N**2
ans = 0
for x in range(1, N+1):
    xx = x**2
    for y in range(x, N+1):
        yy = y**2
        zzww = D - xx - yy
        if -NN <= zzww <= NN:
            if x == y:
                ans += C[zzww]
            else:
                ans += C[zzww] * 2
print(ans)
0