QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#441273 | #8726. Magic Show | zzxLLL | 0 | 0ms | 0kb | C++17 | 1.5kb | 2024-06-14 14:08:16 | 2024-06-14 14:08:16 |
Alice
#include <vector>
#include "Alice.h"
std::vector<std::pair<int, int> > Alice(){
std::vector<std::pair<int, int> > vec;
long long x = setN(5000);
for (int i = 1; i < 5000; i++)
vec.emplace_back(x % i + 1, i + 1);
return vec;
}
Bob
#include <vector>
#include "Bob.h"
typedef long long Int;
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().
inline Int exgcd(Int x, Int y, Int z, Int& p, Int& q) {
// xp + yq = z
if (y == 0) {
p = z / x, q = 0;
return x < 0 ? -x : x;
}
// yp' + (x - x / y * y)q' = z
Int p0, q0;
Int ret = exgcd(y, x % y, z, p0, q0);
// x * q' + y * (-x / y * q' + p') = z
// p = q', q = p' - x / y * q'
p = q0, q = p0 - x / y * q0;
return ret;
}
Int Bob(std::vector<std::pair<int,int> > V){
Int a = 1, b = 0;
// X = b (mod a)
for (auto [A, B] : V) {
A = A - 1, B = B - 1;
if (A > B) std::swap(A, B);
if (b % A == B) continue;
// X = B (mod A)
// X = b (mod a)
// X = b + pa = B + qA
// ap - Aq = B - b
Int p, q;
Int g = exgcd(a, -A, B - b, p, q);
Int dlt = A / g;
p = (p % dlt + dlt) % dlt;
b = b + a * p;
a = a / g * A;
b %= a;
}
return b;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
1 4005
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 2 5 1 6 4 7 2 8 6 9 1 10 6 11 2 12 10 13 2 14 2 15 1 16 6 17 11 18 10 19 16 20 6 21 16 22 2 23 4 24 22 25 6 26 2 27 10 28 2 29 4 30 16 31 7 32 6 33 13 3...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 2 5 1 6 4 7 2 8 6 9 1 10 6 11 2 12 10 13 2 14 2 15 1 16 6 17 11 18 10 19 16 20 6 21 16 22 2 23 4 24 22 25 6 26 2 27 10 28 2 29 4 30 16 31 7 32 6 33 13 3...
output:
2 5000 2512 1 6 1 10 1 16 1 46 1 446 1 1336 2 5 2 12 2 27 2 29 2 53 2 287 2 309 2 573 2 1002 3 4004 4 70 4 139 4 175 4 1335 4 4003 5 4002 6 9 6 17 6 81 6 101 6 201 6 401 6 501 6 801 7 94 7 130 7 1334 7 4000 8 2000 8 3999 9 572 9 3998 10 19 10 37 10 38 10 55 10 109 10 149 10 667 10 1000 10 1333 11 86...
input:
2 5000 2512 1 6 1 10 1 16 1 46 1 446 1 1336 2 5 2 12 2 27 2 29 2 53 2 287 2 309 2 573 2 1002 3 4004 4 70 4 139 4 175 4 1335 4 4003 5 4002 6 9 6 17 6 81 6 101 6 201 6 401 6 501 6 801 7 94 7 130 7 1334 7 4000 8 2000 8 3999 9 572 9 3998 10 19 10 37 10 38 10 55 10 109 10 149 10 667 10 1000 10 1333 11 86...
output:
Subtask #2:
score: 0
Runtime Error
Test #13:
score: 0
Runtime Error
input:
1 17476204
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 1 3 2 4 1 5 5 6 5 7 5 8 5 9 5 10 5 11 10 12 5 13 6 14 5 15 5 16 13 17 1 18 5 19 5 20 5 21 5 22 21 23 23 24 5 25 5 26 19 27 23 28 5 29 22 30 5 31 17 32 13 33 32 ...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 1 3 2 4 1 5 5 6 5 7 5 8 5 9 5 10 5 11 10 12 5 13 6 14 5 15 5 16 13 17 1 18 5 19 5 20 5 21 5 22 21 23 23 24 5 25 5 26 19 27 23 28 5 29 22 30 5 31 17 32 13 33 32 ...
output:
2 5000 2512 1 5 1 35 1 69 2 322 4 1188 5 6 5 9 5 10 5 16 5 19 5 20 5 29 5 37 5 43 5 46 5 57 5 58 5 73 5 77 5 85 5 96 5 101 5 115 5 127 5 147 5 176 5 191 5 201 5 220 5 316 5 351 5 400 5 421 5 439 5 451 5 457 5 505 5 512 5 526 5 533 5 585 5 601 5 631 5 658 5 685 5 701 5 841 5 877 5 1096 5 1198 5 1315 ...
input:
2 5000 2512 1 5 1 35 1 69 2 322 4 1188 5 6 5 9 5 10 5 16 5 19 5 20 5 29 5 37 5 43 5 46 5 57 5 58 5 73 5 77 5 85 5 96 5 101 5 115 5 127 5 147 5 176 5 191 5 201 5 220 5 316 5 351 5 400 5 421 5 439 5 451 5 457 5 505 5 512 5 526 5 533 5 585 5 601 5 631 5 658 5 685 5 701 5 841 5 877 5 1096 5 1198 5 1315 ...
output:
Subtask #3:
score: 0
Runtime Error
Test #25:
score: 0
Runtime Error
input:
1 355365355024496523
output:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 4 5 4 6 4 7 1 8 4 9 4 10 4 11 4 12 4 13 6 14 8 15 4 16 12 17 15 18 4 19 19 20 4 21 1 22 4 23 10 24 4 25 24 26 6 27 13 28 8 29 11 30 4 31 7 32 12 33 4 34...
input:
a890c6696058af3ad84e267191c856938f206a8ef7c63581510cdfa15e45f9c07d82b6a58fe3c8183e2b8f4b976dd90fbca50f420ce3dcf29a3d6a73adf47022 1 5000 1 2 2 3 1 4 4 5 4 6 4 7 1 8 4 9 4 10 4 11 4 12 4 13 6 14 8 15 4 16 12 17 15 18 4 19 19 20 4 21 1 22 4 23 10 24 4 25 24 26 6 27 13 28 8 29 11 30 4 31 7 32 12 33 4 34...
output:
2 5000 2512 1 1138 4 5 4 6 4 9 4 10 4 12 4 16 4 19 4 37 4 46 4 56 4 67 4 73 4 89 4 100 4 111 4 166 4 199 4 265 4 284 4 331 4 441 4 567 4 991 4 1133 4 1699 4 1981 4 2265 4 2548 4 3114 4 3961 6 27 6 54 7 94 8 29 10 38 10 70 10 139 10 167 10 499 10 852 10 3072 12 17 12 65 15 120 15 848 15 1310 18 180 1...
input:
2 5000 2512 1 1138 4 5 4 6 4 9 4 10 4 12 4 16 4 19 4 37 4 46 4 56 4 67 4 73 4 89 4 100 4 111 4 166 4 199 4 265 4 284 4 331 4 441 4 567 4 991 4 1133 4 1699 4 1981 4 2265 4 2548 4 3114 4 3961 6 27 6 54 7 94 8 29 10 38 10 70 10 139 10 167 10 499 10 852 10 3072 12 17 12 65 15 120 15 848 15 1310 18 180 1...