QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#524643 | #6558. Allergen Testing | amirreza# | WA | 3ms | 3616kb | C++23 | 986b | 2024-08-19 22:08:17 | 2024-08-19 22:08:18 |
Judging History
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();
}
詳細信息
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'