QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#238838#6558. Allergen TestingFyind#WA 2ms3644kbC++20883b2023-11-04 17:41:202023-11-04 17:41:20

Judging History

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

  • [2023-11-04 17:41:20]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3644kb
  • [2023-11-04 17:41:20]
  • 提交

answer

#include <bits/stdc++.h>
#define mp(x, y) make_pair(x, y)
#define fi first 
#define se second
using namespace std;
typedef long long ll;

void solve() {
    ll n, d;
    cin >> n >> d;
    if (n == 1) {
        cout << 0 << '\n';
        return;
    }
    --n;
    ll cnt = 0, cur = n;
    while (cur)
        ++cnt, cur >>= 1;
    // cout << cnt << endl;
    ll l = 0, r = cnt * cnt + 500, ans = 0x3f3f3f3f;
    while (l < r) {
        ll mid = l + r >> 1;
        if (((2 * mid) - min(d, mid) + 1) * min(d, mid) / 2 >= cnt)
            ans = min(ans, mid), r = mid;
        else
            l = mid + 1;
    }
    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LLOCAL
    freopen("a.in", "r", stdin);
    #endif
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
4 1

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3644kb

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
11
10
10
10
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
10
10
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
10
10
10
10
10
10
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
10
10
10
11
11
11
11
10
10
10
10
10
10
10
10
10...

result:

wrong answer 4th lines differ - expected: '1', found: '11'