QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524675 | #6558. Allergen Testing | amirreza# | WA | 36ms | 480224kb | C++23 | 1.5kb | 2024-08-19 23:24:35 | 2024-08-19 23:24:35 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#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 M = 61;
const int N = 1e6 + 7;
const LL INF = 1e18 + 5;
LL dp[M][N];
LL nCr[M][M];
void calc() {
nCr[0][0] = 1;
F0R(i, M) F0R(j, M) if (i + j) nCr[i][j] = min(INF, (i - 1 >= 0 ? nCr[i - 1][j] : 0) + (i - 1 >= 0 && j - 1 >= 0 ? nCr[i - 1][j - 1] : 0));
F0R(i, M) F0R(j, N) dp[i][j] = INF;
F0R(i, M) dp[i][0] = 1;
F0R(i, M) FOR(j, 1, N) {
bool done = 0;
dp[i][j] = 0;
F0R(x, i + 1) {
if (dp[i][j] + (__int128)nCr[i][x] * dp[i - x][j - 1] < INF) {
dp[i][j] += nCr[i][x] * dp[i - x][j - 1];
}
else {
dp[i][j] = INF;
done = 1;
break;
}
}
if (done) {
break;
}
}
return;
}
void solve() {
LL n, d;
cin >> n >> d;
if (d >= n - 1) {
cout << 1 << '\n';
return;
}
if (n <= (__int128)d * d) {
cout << 2 << '\n';
return;
}
F0R(i, M) if (dp[i][min(d, (LL)N - 1)] >= n) {
cout << i << '\n';
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: 36ms
memory: 480224kb
input:
1 4 1
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 36ms
memory: 480160kb
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 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 3 3 3 4 3 3 3 4 3 3 3 4 3 3 3 4 3 3 3 4 3 3 3 4 3 3 3 4 3 3 3 4 3 3 3 4 4 4 4 5 4 4 4 5 4 4 4 5 4 4 4 5 4 4 4 5 4 4 4 5 4 4 4 5 4 4 4 5 4 4 4 5 4 4 4 5 5 5 5 6 5 5 5 6 5 5 5 6 5 5 5 6 5 5 5 6 5 5 5 6 5 5...
result:
wrong answer 1st lines differ - expected: '0', found: '1'