QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#238532#6558. Allergen TestingFyind#WA 8ms3612kbC++17710b2023-11-04 16:58:322023-11-04 16:58:32

Judging History

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

  • [2023-11-04 16:58:32]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3612kb
  • [2023-11-04 16:58:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define _ <<" "<<
#define sz(x) ((int) (x).size())
typedef pair<int, int> pii;
typedef long long ll;
const int maxn = 5e5 + 5;


ll n, d;

ll calc(ll tn, ll tx) {
    if (tn <= 1) return 0;
    if (tx == 0) return 2e18;
    return calc(tn/(tx+1), tx-1) + 1;
}

bool check(ll x) {
   return calc(n, x) <= d; 
}

void run_case() {
    cin >> n >> d;
    ll L = 0, R = 1e18;
    while (L < R) {
        ll M = (L+R)/2;
        if (check(M)) R = M;
        else L = M+1;
    }
    cout << L << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while (T--) run_case();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

1
4 1

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 8ms
memory: 3580kb

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
500000000000000000
0
19
18
18
18
18
19
19
19
19
18
18
18
18
18
18
18
18
19
19
19
19
19
19
19
19
18
18
18
18
17
17
17
17
19
19
19
19
18
18
18
18
19
19
19
19
19
19
19
19
19
19
19
19
18
18
18
18
17
17
17
17
19
19
19
19
19
19
19
19
18
18
18
18
18
18
18
18
19
19
19
19
18
18
18
18
18
18
18
18
18
18
18
1...

result:

wrong answer 2nd lines differ - expected: '60', found: '500000000000000000'