QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#354650 | #6558. Allergen Testing | Delay_for_five_minutes# | WA | 63ms | 503656kb | C++11 | 1.9kb | 2024-03-15 20:13:46 | 2024-03-15 20:13:47 |
Judging History
answer
#include<bits/stdc++.h>
const long long MAXN = 1e18;
long long mul(long long x,long long y) {
if (__int128(x) * y >= MAXN) {
return MAXN;
}
else {
return x * y;
}
}
long long add(long long x, long long y) {
if (x + y >= MAXN) {
return MAXN;
}
else {
return x + y;
}
}
long long f1(long long d) {
return d + 1;
}
long long f2(long long d) {
return mul(d + 1, d + 1);
}
long long dp[1000005][64];
int mx[64], N = 62;
long long C[64][64];
void presolve() {
C[0][0] = 1;
for(int i = 1; i <= N; i++) {
C[i][0] = 1;
for(int j = 1; j <= i; j++) {
C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
}
}
for(int i = 0; i <= N; i++) {
dp[0][i] = 1;
}
int d = 1;
while(N >= 3) {
for(int i = 0; i <= N; i++) {
for(int j = 0; j <= i; j++) {
dp[d][i] = add(dp[d][i], mul(dp[d - 1][j], C[i][j]));
}
}
// if (d <= 4) {
// for(int j = 0; j <= 15; j++) {
// std::cout << dp[d][j] << " " ;
// }
// std::cout << std::endl;
// }
while(dp[d][N] >= MAXN) {
mx[N] = d;
N--;
}
d++;
}
}
int main() {
// freopen("in.txt","r",stdin);
presolve();
int q;
std::cin >> q;
for(int i = 1; i <= q; i++) {
long long n, d;
std::cin >> n >> d;
if (f1(d) >= n) {
std::cout << 1 << std::endl;
}
else if (f2(d) >= n) {
std::cout << 2 << std::endl;
}
else {
for(int j = 3; j <= 62; j++) {
if (d >= mx[j] || dp[d][j] >= n) {
std::cout << j << std::endl;
break;
}
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 59ms
memory: 503656kb
input:
1 4 1
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 63ms
memory: 503624kb
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 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 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'