結果

問題 No.2624 Prediction by Average
ユーザー srjywrdnprkt
提出日時 2024-02-29 12:35:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 2,354 ms
コンパイル使用メモリ 195,720 KB
最終ジャッジ日時 2025-02-19 21:59:21
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

    //87.500 <= average < 87.501
    //87500 <= 1000*average < 87501
    //87500 <= 1000*s/k < 87501
    //87500k/1000 <= s < 87501k/1000が整数解を持つk(1000周期)
    //87500k <= 1000s < 87501k

    ll T, N, S, ans, x;
    string U;
    cin >> T;
    while(T--){
        cin >> N >> U;
        ans = 0;
        U.erase(remove(U.begin(), U.end(), '.'), U.end());
        S = stoll(U);
        //i=0では必ず条件を満たす(sum=S)
        ans += N/1000;
        for (int i=1; i<1000; i++){
            x = (S*i+999) / 1000 * 1000;
            if (x < (S+1)*i && i <= N){
                //N以下の整数のうち、1000で割ってi余るものの個数
                ans += (N-i)/1000+1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}
0