結果

問題 No.800 四平方定理
ユーザー heno239heno239
提出日時 2019-03-15 16:23:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 433 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 47,336 KB
最終ジャッジ日時 2023-09-14 12:28:08
合計ジャッジ時間 15,028 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
47,108 KB
testcase_01 AC 57 ms
47,112 KB
testcase_02 AC 49 ms
47,108 KB
testcase_03 AC 49 ms
47,148 KB
testcase_04 AC 48 ms
47,184 KB
testcase_05 AC 50 ms
47,104 KB
testcase_06 AC 55 ms
47,208 KB
testcase_07 AC 53 ms
47,204 KB
testcase_08 AC 59 ms
47,212 KB
testcase_09 AC 52 ms
47,220 KB
testcase_10 AC 605 ms
47,180 KB
testcase_11 AC 637 ms
47,144 KB
testcase_12 AC 671 ms
47,220 KB
testcase_13 AC 558 ms
47,104 KB
testcase_14 AC 610 ms
47,208 KB
testcase_15 AC 672 ms
47,264 KB
testcase_16 AC 617 ms
47,140 KB
testcase_17 AC 611 ms
47,232 KB
testcase_18 AC 718 ms
47,172 KB
testcase_19 AC 721 ms
47,212 KB
testcase_20 AC 41 ms
47,232 KB
testcase_21 AC 41 ms
47,160 KB
testcase_22 AC 720 ms
47,112 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 39 ms
47,260 KB
testcase_27 AC 40 ms
47,116 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

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]*5000001
  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):
          if p[i]+p[j]<=5000000:
            ans+=2*cnt[p[i]+p[j]]
  print(ans)
solve()
0