QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227620#6558. Allergen TestingNerovix#WA 23ms3492kbC++20718b2023-10-27 19:53:062023-10-27 19:53:06

Judging History

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

  • [2023-10-27 19:53:06]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:3492kb
  • [2023-10-27 19:53:06]
  • 提交

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++) {
        f *= p - t;
        if(f >= n || C >= n) return 1;
        now += f * C;
        if(now >= n) return 1;
        C = C * (d - t) / (t + 1);
    }
    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: 100
Accepted
time: 0ms
memory: 3464kb

input:

1
4 1

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 23ms
memory: 3492kb

input:

10000
1 1
1000000000000000000 1
1 1000000000000000000
1000000000000000000 1000000000000000000
26615519354743225 163142634
26615519354743225 163142634
26615519354743224 163142634
26615519354743226 163142634
847997831064072529 920867976
847997831064072529 920867976
847997831064072528 920867976
8479978...

output:

1
20
1
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6...

result:

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