結果

問題 No.152 貯金箱の消失
ユーザー 6soukiti296soukiti29
提出日時 2017-09-18 16:50:08
言語 Nim
(2.0.0)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 2,911 ms
コンパイル使用メモリ 68,028 KB
実行使用メモリ 17,056 KB
最終ジャッジ日時 2023-09-12 15:12:36
合計ジャッジ時間 3,727 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 8 ms
4,564 KB
testcase_08 AC 41 ms
16,992 KB
testcase_09 AC 42 ms
17,056 KB
testcase_10 AC 32 ms
11,924 KB
testcase_11 AC 19 ms
8,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 31) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,math,algorithm
const
    m = 1_000_003
var
    L = stdin.readline.parseInt
    cnt : int
    items = newSeq[tuple[x,y,z : int]](0)
for a in 1..(floor(sqrt(L / 2)) / 2).int:
    for b in 0..(floor(sqrt(L / 2)) / 2).int:
        var
            x = abs(a * a * 4 - (b * 2 + 1) * (b * 2 + 1))
            y = 2 * (2 * a) * (2 * b + 1)
            z = a * a * 4 + (b * 2 + 1) * (b * 2 + 1)
        if (x + y + z) * 4 <= L and gcd(x,y) == 1:
            cnt += 1
            #echo @[x,y,z].join(" ")
            items.add((x,y,z))
    cnt = cnt mod m
echo cnt
0