結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
78,292 KB
testcase_01 AC 68 ms
78,420 KB
testcase_02 AC 66 ms
78,336 KB
testcase_03 AC 65 ms
78,280 KB
testcase_04 AC 65 ms
78,260 KB
testcase_05 AC 65 ms
78,384 KB
testcase_06 AC 70 ms
78,224 KB
testcase_07 AC 68 ms
78,308 KB
testcase_08 AC 73 ms
78,328 KB
testcase_09 AC 68 ms
78,284 KB
testcase_10 AC 550 ms
78,388 KB
testcase_11 AC 585 ms
78,468 KB
testcase_12 AC 618 ms
78,316 KB
testcase_13 AC 524 ms
78,352 KB
testcase_14 AC 555 ms
78,224 KB
testcase_15 AC 614 ms
78,316 KB
testcase_16 AC 561 ms
78,320 KB
testcase_17 AC 564 ms
78,312 KB
testcase_18 AC 661 ms
78,316 KB
testcase_19 AC 666 ms
78,332 KB
testcase_20 AC 58 ms
78,228 KB
testcase_21 AC 57 ms
78,372 KB
testcase_22 AC 675 ms
78,320 KB
testcase_23 AC 1,108 ms
78,392 KB
testcase_24 AC 987 ms
78,268 KB
testcase_25 AC 1,103 ms
78,312 KB
testcase_26 AC 55 ms
78,264 KB
testcase_27 AC 57 ms
78,232 KB
testcase_28 AC 995 ms
78,368 KB
testcase_29 AC 1,052 ms
78,376 KB
testcase_30 AC 986 ms
78,428 KB
testcase_31 AC 918 ms
78,248 KB
testcase_32 AC 1,005 ms
78,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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