QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#349063#6558. Allergen Testingrealcomplex0#WA 26ms3612kbC++20836b2024-03-09 23:25:022024-03-09 23:25:03

Judging History

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

  • [2024-03-09 23:25:03]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:3612kb
  • [2024-03-09 23:25:02]
  • 提交

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

详细

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'