QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#349000#6558. Allergen Testingrealcomplex0#WA 28ms3660kbC++20800b2024-03-09 22:52:132024-03-09 22:52:14

Judging History

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

  • [2024-03-09 22:52:14]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:3660kb
  • [2024-03-09 22:52:13]
  • 提交

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;
    }
}

Details

Tip: Click on the bar to expand more detailed information

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'