結果

問題 No.800 四平方定理
コンテスト
ユーザー ikd
提出日時 2019-03-17 22:06:08
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 403 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,506 ms
コンパイル使用メモリ 68,728 KB
実行使用メモリ 15,944 KB
最終ジャッジ日時 2026-03-23 01:54:54
合計ジャッジ時間 62,388 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other AC * 12 TLE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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