QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524643#6558. Allergen Testingamirreza#WA 3ms3616kbC++23986b2024-08-19 22:08:172024-08-19 22:08:18

Judging History

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

  • [2024-08-19 22:08:18]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3616kb
  • [2024-08-19 22:08:17]
  • 提交

answer

#include <bits/stdc++.h>

#define FOR(i, x, n) for(int i = x; i < n; i++)
#define F0R(i, n) FOR(i, 0, n)
#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)
#define R0F(i, n) ROF(i, 0, n)

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long LL;

const int N = 63;
const LL INF = 1e18 + 5;

LL dp[N][N];
LL nCr[N][N];

void calc() {
    nCr[0][0] = 1;
    F0R(i, N) F0R(j, N) if (i + j) nCr[i][j] = (i - 1 >= 0 ? nCr[i - 1][j] : 0) + (i - 1 >= 0 && j - 1 >= 0 ? nCr[i - 1][j - 1] : 0);

    F0R(i, N) dp[i][0] = 1;

    F0R(i, N) FOR(j, 1, N) F0R(x, i + 1) {
        if ((__int128)nCr[i][x] * dp[i - x][j - 1] < INF)
            dp[i][j] += nCr[i][x] * dp[i - x][j - 1];
    }

    return;
}

void solve() {
    LL n, d;
    cin >> n >> d;
    
    F0R(i, N) if (dp[i][min(d, (LL)N - 1)] >= n) {
        cout << i << endl;
        return;
    }
}

int main() {
    IOS;

    calc();
    int t; cin >> t;
    while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3604kb

input:

1
4 1

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3616kb

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
16
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
9
9
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
9
9
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
9
9
9
9
9
9
9
10
10
...

result:

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