結果

問題 No.152 貯金箱の消失
コンテスト
ユーザー むらため
提出日時 2019-01-27 01:10:47
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 499 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,182 ms
コンパイル使用メモリ 68,432 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-22 10:11:56
合計ジャッジ時間 2,887 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

proc solve(n:int):int =
  for x in 1..n:
    for y in (x+1)..n:
      let a = (x * x - y * y).abs
      let b = 2 * x * y
      let c = x * x + y * y
      if a + b + c > n : break
      if a.gcd(b).gcd(c) != 1 : continue
      result += 1
let n = scan() div 4
echo n.solve()
0