結果

問題 No.2624 Prediction by Average
ユーザー halshals
提出日時 2024-03-01 17:40:14
言語 Julia
(1.10.2)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 971 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 7,072 KB
実行使用メモリ 255,128 KB
最終ジャッジ日時 2024-04-09 14:36:44
合計ジャッジ時間 3,506 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 393 ms
251,920 KB
testcase_01 AC 395 ms
254,848 KB
testcase_02 AC 395 ms
252,828 KB
testcase_03 AC 391 ms
253,112 KB
testcase_04 AC 394 ms
251,980 KB
testcase_05 AC 395 ms
255,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function main()
    t = int(input())
    ns = [inputs() for _ = 1:t]
    for (n_, s_) = ns
        n = int(n_)
        s = int(replace(s_, "." => ""))
        ans = max(n - 1000, 0)  # 1000以下の場合は全探索
        for i = 1:min(n, 1000)
            # S*i <= goukei <= (S+0.001)*iとなる整数goukeiの個数をカウント
            goukei = ceil(Int, s * i / 1000) * 1000
            if s * i <= goukei < (s + 1) * i
                ans += 1
            end
        end
        println(ans)
    end
end
# --------input func----------
input() = readline()
inputs() = split(readline())
int(s::AbstractChar) = parse(Int, s)
int(s::AbstractString) = parse(Int, s)
int(v::AbstractArray) = map(x -> parse(Int, x), v)
debug(x...) = println(stderr, x...)
function _main()
    isequal(abspath(PROGRAM_FILE), @__FILE__) && return main()
    mystdin = joinpath(abspath(@__DIR__), "myinput.txt")
    redirect_stdio(stdin=mystdin) do
        main()
    end
end
_main()
0