QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#348932 | #6558. Allergen Testing | realcomplex0# | TL | 0ms | 3740kb | C++20 | 728b | 2024-03-09 22:23:08 | 2024-03-09 22:23:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool ok(ll n, ll s, ll d) {
if(n<=d) return true;
if(d==0) return false;
bool a = ok((n+s)/(s+1),s,d-1);
bool b = false;
for(ll i=1;i<=s;i++){
b |= ok(n-((ll)1<<s),s-i,d);
}
return a || b;
}
int main() {
ios_base::sync_with_stdio(false);
ll t;
cin>>t;
while(t--){
ll n, d;
cin>>n>>d;
ll l=0, r=61;
ll res=n;
while(l<=r){
ll m=(l+r)/2;
if(ok(n,m,d)){
res=min(res,m);
r=m-1;
}else{
l=m+1;
}
}
cout<<res<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
input:
1 4 1
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Time Limit Exceeded
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:
0