結果

問題 No.2624 Prediction by Average
ユーザー loop0919loop0919
提出日時 2024-01-05 02:37:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 3,204 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 77,220 KB
最終ジャッジ日時 2024-01-05 02:37:44
合計ジャッジ時間 1,716 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
64,296 KB
testcase_01 AC 99 ms
77,092 KB
testcase_02 AC 104 ms
77,092 KB
testcase_03 AC 52 ms
63,656 KB
testcase_04 AC 107 ms
77,220 KB
testcase_05 AC 106 ms
77,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import re

def solve():
    N, S = input().split()
    
    assert re.match(r'^(([1-9][0-9]*)|0)\.[0-9]{3}$', S), "Sの小数の表記に違反があります"
    
    N = int(N); S = int(S.replace(".", ""))
    
    assert 1 <= N <= 10**13, "Nの制約に違反があります"
    assert 0 <= S <= 100 * 1000, "Sの制約に違反があります"
    
    cnt = 0
    for i in range(1, min(N, 999) + 1):
        left = S*i; right = left + i
        if left <= right // 1000 * 1000 < right:
            cnt += 1
    
    cnt += max(N - 999, 0)
    print(cnt)

T = int(input())
assert 1 <= T <= 1000, "Tの制約に違反しています"
for _ in range(T):
    solve()

try:
    input()
    raise AssertionError("不要な文字があります")
except EOFError:
    pass # 正常
0