QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#349063 | #6558. Allergen Testing | realcomplex0# | WA | 26ms | 3612kb | C++20 | 836b | 2024-03-09 23:25:02 | 2024-03-09 23:25:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool ok(ll n, ll s, ll d) {
if(n<=1) return true;
if(d==0||s==0) return false;
if(n<=(d+1)) return true;
if(((ll)1<<s)>=n) return true;
return ok((n+s)/(s+1),s-1,d-1);
}
bool ok2(ll n, ll s, ll d) {
bool res=false;
for(ll i=0;i<=s;i++){
res|=ok(n-((ll)1<<i)+1,s-i,d);
}
return res;
}
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(ok2(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: 3540kb
input:
1 4 1
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 26ms
memory: 3612kb
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 60 0 1 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 14 14 14 14 15 15 15 15 15 15 15 15 14 14 14 14 14 14 14 14 14 14 14 14 15 15 15 15 14 14 14 14 14 14 14 14 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 14 14 14 14 15 ...
result:
wrong answer 5th lines differ - expected: '2', found: '11'