結果

問題 No.2624 Prediction by Average
ユーザー AngrySadEightAngrySadEight
提出日時 2023-12-29 11:10:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,186 bytes
コンパイル時間 892 ms
コンパイル使用メモリ 70,984 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-29 11:10:03
合計ジャッジ時間 1,119 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 5 ms
6,676 KB
testcase_02 AC 7 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 5 ms
6,676 KB
testcase_05 AC 6 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <iostream>
#include <string>
using namespace std;

int main() {
    int T;
    cin >> T;
    assert(T >= 1);
    assert(T <= 1000);
    while (T--) {
        long long N;
        cin >> N;
        assert(N >= 1);
        assert(N <= 10000000000000);
        string S;
        cin >> S;
        int len = S.size();
        long long score =
            stoll(S.substr(0, len - 4)) * 1000 + stoll(S.substr(len - 3, 3));
        assert(score >= 0 && score <= 100000);
        if (N <= 1000) {
            long long ans = 0;
            for (int i = 1; i <= N; i++) {
                long long lb = score * i;
                long long ub = (score + 1) * i - 1;
                if ((lb - 1) / 1000 != ub / 1000) {
                    ans++;
                }
            }
            cout << ans << endl;
        } else {
            long long ans = N - 1000;
            for (int i = 1; i <= 1000; i++) {
                long long lb = score * i;
                long long ub = (score + 1) * i - 1;
                if ((lb - 1) / 1000 != ub / 1000) {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }
}
0