QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#524673 | #6558. Allergen Testing | amirreza# | RE | 15ms | 151176kb | C++23 | 1.5kb | 2024-08-19 23:20:22 | 2024-08-19 23:20:22 |
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) dp[i][0] = 1;
F0R(i, M) FOR(j, 1, N) {
bool done = 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, N) if (dp[i][min(d, (LL)N - 1)] >= n) {
cout << i << '\n';
return;
}
}
int main() {
IOS;
calc();
int t; cin >> t;
while(t--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 15ms
memory: 151176kb
input:
1 4 1
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Runtime Error
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...