QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#227620 | #6558. Allergen Testing | Nerovix# | WA | 23ms | 3492kb | C++20 | 718b | 2023-10-27 19:53:06 | 2023-10-27 19:53:06 |
Judging History
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'