結果

問題 No.800 四平方定理
ユーザー uto_qk
提出日時 2019-03-17 23:03:52
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 604 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 83,096 KB
最終ジャッジ日時 2024-07-08 01:47:18
合計ジャッジ時間 4,692 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 10 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import math as ma
N, D = map(int,input().split())
ans = 0
for x in range(1,N+1):
    for y in range(x,N+1):
        if (x**2 + y**2 - D) % 4 == 2:
            continue
        for z in range(y,N+1):
            w = x**2 + y**2 + z**2 - D
            if w >= 1 and w <= N**2 and (w % 4 == 0 or w % 4 == 1):
                sq = int(ma.sqrt(w))
                if w == sq**2:
                    if x == y and y == z:
                        ans += 1
                    elif x == y or y == z or z == x:
                        ans += 3
                    else:
                        ans += 6
print(ans)
0