結果

問題 No.800 四平方定理
ユーザー heno239
提出日時 2019-03-15 16:16:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,774 ms / 2,000 ms
コード長 338 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 81,024 KB
最終ジャッジ日時 2024-07-01 19:51:14
合計ジャッジ時間 26,837 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
  n,d=map(int,input().split())
  cnt=[0]*9000001
  for i in range(1,n+1):
      for j in range(1,n+1):
          s=i*i-j*j+d
          if s>=0:
              cnt[s]+=1
  ans=0
  for i in range(1,n+1):
    ans+=cnt[2*i*i]
  for i in range(1,n+1):
      for j in range(i+1,n+1):
        ans+=2*cnt[i*i+j*j]
  print(ans)
solve()
0