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...) if isequal(abspath(PROGRAM_FILE), @__FILE__) main() end