結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
78,264 KB
testcase_01 AC 68 ms
78,436 KB
testcase_02 AC 64 ms
78,380 KB
testcase_03 AC 65 ms
78,276 KB
testcase_04 AC 65 ms
78,368 KB
testcase_05 AC 65 ms
78,364 KB
testcase_06 AC 73 ms
78,376 KB
testcase_07 AC 70 ms
78,260 KB
testcase_08 AC 76 ms
78,332 KB
testcase_09 AC 69 ms
78,268 KB
testcase_10 AC 584 ms
78,452 KB
testcase_11 AC 619 ms
78,268 KB
testcase_12 AC 644 ms
78,336 KB
testcase_13 AC 536 ms
78,452 KB
testcase_14 AC 584 ms
78,292 KB
testcase_15 AC 645 ms
78,296 KB
testcase_16 AC 589 ms
78,436 KB
testcase_17 AC 591 ms
78,352 KB
testcase_18 AC 689 ms
78,296 KB
testcase_19 AC 687 ms
78,356 KB
testcase_20 AC 56 ms
78,464 KB
testcase_21 AC 56 ms
78,396 KB
testcase_22 AC 688 ms
78,296 KB
testcase_23 AC 1,153 ms
78,400 KB
testcase_24 AC 1,036 ms
78,264 KB
testcase_25 AC 1,156 ms
78,416 KB
testcase_26 AC 58 ms
78,236 KB
testcase_27 AC 57 ms
78,356 KB
testcase_28 AC 1,029 ms
78,328 KB
testcase_29 AC 1,111 ms
78,296 KB
testcase_30 AC 1,034 ms
78,404 KB
testcase_31 AC 967 ms
78,300 KB
testcase_32 AC 1,067 ms
78,356 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