結果

問題 No.2624 Prediction by Average
ユーザー miiitomimiiitomi
提出日時 2024-02-09 22:33:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 207,028 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-02-09 22:33:20
合計ジャッジ時間 2,440 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<vector<bool>> S(1000, vector<bool>(1000, false));

void solve() {
    ll n;
    string t;
    cin >> n >> t;
    int m = 0, b = 1;
    for (int k = 0; k < 3; k++) {
        m += b * (int)(t[(int)t.size()-1-k] - '0');
        b *= 10;
    }

    ll ans = 0;
    for (int i = 1; i <= min(n, 999LL); i++) {
        ans += S[i][m];
    }
    if (n >= 1000) ans += n - 999;
    cout << ans << "\n";
}

int main() {
    for (int i = 1; i <= 999; i++) {
        for (int j = 0; j < i; j++) {
            int x = (j * 1000) / i;
            S[i][x] = true;
        }
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int T = 1;
    cin >> T;
    while (T--) solve();
}
0