結果

問題 No.800 四平方定理
ユーザー heno239heno239
提出日時 2019-03-15 16:14:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,655 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 10,460 KB
実行使用メモリ 78,464 KB
最終ジャッジ日時 2023-09-14 12:24:59
合計ジャッジ時間 24,741 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
78,312 KB
testcase_01 AC 73 ms
78,236 KB
testcase_02 AC 69 ms
78,352 KB
testcase_03 AC 70 ms
78,320 KB
testcase_04 AC 70 ms
78,200 KB
testcase_05 AC 69 ms
78,340 KB
testcase_06 AC 77 ms
78,192 KB
testcase_07 AC 76 ms
78,328 KB
testcase_08 AC 82 ms
78,220 KB
testcase_09 AC 75 ms
78,328 KB
testcase_10 AC 807 ms
78,280 KB
testcase_11 AC 892 ms
78,260 KB
testcase_12 AC 906 ms
78,192 KB
testcase_13 AC 801 ms
78,204 KB
testcase_14 AC 860 ms
78,264 KB
testcase_15 AC 902 ms
78,292 KB
testcase_16 AC 856 ms
78,340 KB
testcase_17 AC 870 ms
78,216 KB
testcase_18 AC 956 ms
78,268 KB
testcase_19 AC 958 ms
78,464 KB
testcase_20 AC 56 ms
78,384 KB
testcase_21 AC 56 ms
78,192 KB
testcase_22 AC 965 ms
78,328 KB
testcase_23 AC 1,655 ms
78,352 KB
testcase_24 AC 1,538 ms
78,380 KB
testcase_25 AC 1,653 ms
78,324 KB
testcase_26 AC 56 ms
78,192 KB
testcase_27 AC 56 ms
78,408 KB
testcase_28 AC 1,515 ms
78,264 KB
testcase_29 AC 1,599 ms
78,340 KB
testcase_30 AC 1,529 ms
78,256 KB
testcase_31 AC 1,423 ms
78,412 KB
testcase_32 AC 1,561 ms
78,460 KB
権限があれば一括ダウンロードができます

ソースコード

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):
      for j in range(1,n+1):
        ans+=cnt[i*i+j*j]
  print(ans)
solve()
0