QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227621#6558. Allergen TestingNerovix#WA 0ms3592kbC++20718b2023-10-27 19:55:162023-10-27 19:55:17

Judging History

你现在查看的是最新测评结果

  • [2023-10-27 19:55:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2023-10-27 19:55:16]
  • 提交

answer

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

typedef long long ll;


ll n, d;

inline bool check(ll p) {
    __int128_t C = 1, now = 0, f = 1;
    for(ll t = 0; t <= p; t++) {
        if(f >= n || C >= n) return 1;
        now += f * C;
        if(now >= n) return 1;
        C = C * (d - t) / (t + 1);
        f *= p - t;
    }
    return now >= n;
}

inline void Solve() {
    cin >> n >> d;
    ll l = 1, r = n, ans = n;
    while(l <= r) {
        ll mid = l + r >> 1;
        if(check(mid)) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    cout << ans << '\n';
}

signed main() {
    int t;
    cin >> t;
    for(; t--; ) {
        Solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3592kb

input:

1
4 1

output:

3

result:

wrong answer 1st lines differ - expected: '2', found: '3'