結果

問題 No.800 四平方定理
ユーザー ikdikd
提出日時 2019-03-17 22:06:08
言語 Nim
(2.0.2)
結果
TLE  
実行時間 -
コード長 403 bytes
コンパイル時間 3,391 ms
コンパイル使用メモリ 68,156 KB
実行使用メモリ 9,076 KB
最終ジャッジ日時 2023-09-14 15:27:05
合計ジャッジ時間 8,673 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
4,376 KB
testcase_01 AC 82 ms
4,376 KB
testcase_02 AC 50 ms
4,376 KB
testcase_03 AC 59 ms
4,376 KB
testcase_04 AC 46 ms
4,380 KB
testcase_05 AC 56 ms
4,380 KB
testcase_06 AC 105 ms
4,380 KB
testcase_07 AC 60 ms
4,376 KB
testcase_08 AC 84 ms
4,380 KB
testcase_09 AC 87 ms
4,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

proc main() =
  let
    nd = stdin.readLine.strip.split.map(parseInt)
    (n, d) = (nd[0], nd[1])
  var sq = newSeq[bool](n * n + 1)
  for i in 1..n:
    sq[i * i] = true
  var ans: int64 = 0
  for x in 1..n:
    for y in 1..n:
      for z in 1..n:
        let w2 = x * x + y * y + z * z - d
        if w2 >= 0 and w2 <= n * n and sq[w2]:
          ans += 1
  echo ans
main()
0