QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#220776 | #6549. Two Missing Numbers | ucup-team191# | 0 | 1ms | 1616kb | C++14 | 2.4kb | 2023-10-20 20:19:09 | 2023-10-20 20:19:09 |
answer
#include <cstdio>
#include <array>
#include <bitset>
using namespace std;
typedef unsigned long long ull;
typedef bitset < 64 > poly;
int q;
bitset < 65 > MOD;
const int MOD_DEG = 64;
inline poly add(poly A, poly B) {
return A ^ B;
}
inline poly mul(poly A, poly B) {
bitset < 128 > ret;
for(int i = 0;i < 64;i++) {
for(int j = 0;j < 64;j++) {
if(A[i] && B[j])
ret[i + j] = !ret[i + j];
}
}
for(int i = 127;i >= MOD_DEG;i--) {
if(!ret[i]) continue;
for(int j = 0;j <= MOD_DEG;j++)
if(MOD[j]) ret[i - MOD_DEG + j] = !ret[i - MOD_DEG + j];
}
poly novi;
for(int i = 0;i < 64;i++) novi[i] = ret[i];
return novi;
}
inline poly divide(poly A, poly B) {
for(int i = 0;i < MOD_DEG;i++) {
if(i) A = mul(A, B);
B = mul(B, B);
}
return A;
}
poly bs[64];
int ima[64], tko[64];
void add_bs(poly A, int ja) {
for(int i = 0;i < 64;i++) {
if(!A[i]) continue;
if(!ima[i]) {
ima[i] = 1; bs[i] = A;
tko[i] = ja;
} else {
A ^= bs[i];
}
}
}
poly inverse(poly A) {
poly ret;
for(int i = 0;i < 64;i++) {
if(A[i]) {
A ^= bs[i];
ret[tko[i]] = 1;
}
}
return ret;
}
inline poly solve(poly B, poly C) { // X ^ 2 + B X = C
for(int i = 0;i < 64;i++) {
poly tmp; tmp[i] = 1;
add_bs(add(mul(tmp, tmp), mul(B, tmp)), i);
}
return inverse(C);
}
poly ull_to_poly(ull A) {
poly ret;
for(int i = 0;i < 64;i++)
ret[i] = !!((1ULL << i) & A);
return ret;
}
ull poly_to_ull(poly A) {
ull ret = 0;
for(int i = 0;i < 64;i++)
if(A[i]) ret += 1ULL << i;
return ret;
}
int main(){
MOD[64] = 1; MOD[4] = 1; MOD[3] = 1; MOD[1] = 1; MOD[0] = 1;
int ty; scanf("%d", &ty);
if(ty == 1) {
int n; scanf("%d", &n);
poly A, B;
for(int i = 0;i < n;i++) {
ull tx; scanf("%llu", &tx);
poly x = ull_to_poly(tx);
A = add(A, x);
B = add(B, mul(x, mul(x, x)));
}
printf("%llu %llu\n", poly_to_ull(A), poly_to_ull(B));
} else {
int n; scanf("%d", &n);
ull a, b; scanf("%llu%llu", &a, &b);
poly A = ull_to_poly(a);
poly B = ull_to_poly(b);
for(int i = 0;i < n;i++) {
ull tx; scanf("%llu", &tx);
poly x = ull_to_poly(tx);
A = add(A, x);
B = add(B, mul(x, mul(x, x)));
}
// A = X + Y, B = X ^ 3 + Y ^ 3
poly C = add(divide(B, A), mul(A, A));
poly X = solve(A, C);
printf("%llu %llu\n", poly_to_ull(X), poly_to_ull(add(X, A)));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1604kb
First Run Input
1 5 5 1 4 4 5
First Run Output
1 1
Second Run Input
2 3 1 1 9 9 3
Second Run Output
1 3
result:
ok correct
Test #2:
score: 100
Accepted
time: 0ms
memory: 1608kb
First Run Input
1 1 0
First Run Output
0 0
Second Run Input
2 1 0 0 1
Second Run Output
0 1
result:
ok correct
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 1616kb
First Run Input
1 1 10625130587464985929
First Run Output
10625130587464985929 12511876466917322003
Second Run Input
2 1 10625130587464985929 12511876466917322003 1167154569617655189
Second Run Output
63 9459418612536453347
result:
wrong answer incorrect, read 63 9459418612536453347 but expected 1167154569617655189 10625130587464985929