結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
78,372 KB
testcase_01 AC 71 ms
78,444 KB
testcase_02 AC 67 ms
78,344 KB
testcase_03 AC 67 ms
78,336 KB
testcase_04 AC 66 ms
78,304 KB
testcase_05 AC 68 ms
78,396 KB
testcase_06 AC 73 ms
78,308 KB
testcase_07 AC 71 ms
78,436 KB
testcase_08 AC 76 ms
78,276 KB
testcase_09 AC 71 ms
78,436 KB
testcase_10 AC 631 ms
78,284 KB
testcase_11 AC 681 ms
78,368 KB
testcase_12 AC 700 ms
78,344 KB
testcase_13 AC 597 ms
78,444 KB
testcase_14 AC 642 ms
78,304 KB
testcase_15 AC 708 ms
78,392 KB
testcase_16 AC 656 ms
78,432 KB
testcase_17 AC 655 ms
78,332 KB
testcase_18 AC 747 ms
78,436 KB
testcase_19 AC 746 ms
78,484 KB
testcase_20 AC 56 ms
78,280 KB
testcase_21 AC 56 ms
78,472 KB
testcase_22 AC 744 ms
78,368 KB
testcase_23 AC 1,276 ms
78,436 KB
testcase_24 AC 1,151 ms
78,304 KB
testcase_25 AC 1,267 ms
78,268 KB
testcase_26 AC 57 ms
78,368 KB
testcase_27 AC 57 ms
78,248 KB
testcase_28 AC 1,139 ms
78,296 KB
testcase_29 AC 1,212 ms
78,344 KB
testcase_30 AC 1,145 ms
78,316 KB
testcase_31 AC 1,054 ms
78,296 KB
testcase_32 AC 1,168 ms
78,296 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):
    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