QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239289#6558. Allergen TestingFyind#WA 0ms3740kbC++171.1kb2023-11-04 19:50:212023-11-04 19:50:22

Judging History

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

  • [2023-11-04 19:50:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2023-11-04 19:50:21]
  • 提交

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;
const ll oo = LLONG_MAX/2;
ll c[66][66];

map<pair<ll,ll>,ll> ans;
ll dp[65][65];

ll f(int x, int d) {
    if (d == 1) return 1ll<<x;
    if (x == 1) return 2; 
    if (dp[x][d]) return dp[x][d];
    ll sum = 1;
    for (int k = 1;k < x; ++k) {
        sum += c[x][k];
        ll nxt = f(x-k,d-1);
        if (nxt <= LLONG_MAX/sum)
            dp[x][d] = max(dp[x][d],  nxt * sum + 1);
    }
    return dp[x][d];
}

ll n, d;

void run_case() {
    cin >> n >> d;
    d = min(d, 63*1ll);
    for (int x = 1;x <= 63; ++x) {
        if (f(x,d) >= n) {
            cout << x << '\n';
            return;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    c[0][0] = 1;
    for (int i = 1;i <= 64; ++i) {
        c[i][0] = 1;
        for (int j = 1;j <= 64; ++j) {
            c[i][j] = c[i-1][j-1] + c[i-1][j];
        }
    }
    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: 3716kb

input:

1
4 1

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3740kb

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:

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

result:

wrong answer 1st lines differ - expected: '0', found: '1'