QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#349000 | #6558. Allergen Testing | realcomplex0# | WA | 28ms | 3660kb | C++20 | 800b | 2024-03-09 22:52:13 | 2024-03-09 22:52:14 |
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;
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;
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3484kb
input:
1 4 1
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 28ms
memory: 3660kb
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'