結果

問題 No.2624 Prediction by Average
ユーザー t98slider
提出日時 2024-02-09 22:11:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 607 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 167,084 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-28 15:27:01
合計ジャッジ時間 1,991 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int T;
    cin >> T;
    while(T--){
        ll n, s0, s1, s = 0;
        scanf("%lld %lld.%lld", &n, &s0, &s1);
        s = s0 * 1000 + s1;
        ll ans = 0, c = min(n, 1000ll);
        ans += max(0ll, n - 1000);
        for(ll i = 1; i <= c; i++){
            ll ng = -1, ok = 100 * i, mid;
            while(ng + 1 < ok){
                mid = (ng + ok) / 2;
                (mid * 1000 >= s * i ? ok : ng) = mid;
            }
            ans += (ok * 1000) / i == s;
        }
        printf("%lld\n", ans);
    }
}
0