結果

問題 No.2624 Prediction by Average
ユーザー GOTKAKOGOTKAKO
提出日時 2024-02-09 21:54:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,390 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 206,000 KB
実行使用メモリ 232,320 KB
最終ジャッジ日時 2024-02-09 21:55:02
合計ジャッジ時間 12,364 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,390 ms
232,320 KB
testcase_01 AC 1,367 ms
232,320 KB
testcase_02 AC 1,375 ms
232,320 KB
testcase_03 AC 1,382 ms
232,320 KB
testcase_04 AC 1,309 ms
232,320 KB
testcase_05 AC 1,304 ms
232,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    vector<vector<int>> ok(100001);
    for(int i=1; i<=1000; i++){
        int limit = i*100*1000;
        for(long long s=0; s<=limit; s+=1000){
            long long now = s/i;
            ok.at(now).push_back(i);
        }
    }

    int T; cin >> T;
    while(T--){
        long long N; cin >> N;
        string S; cin >> S;
        reverse(S.begin(),S.end());
        long long T = 0,p10 = 1;
        for(auto c : S){
            if(c == '.') continue;
            T += p10*(c-'0');
            p10 *= 10;
        }

        long long answer = max(0LL,N-999);
        N = min(999LL,N);

        for(auto n : ok.at(T)){
            if(n > N) break;
            answer++;
        }
        cout << answer << endl;
    }
}
0