| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1293572 | sh1ka | Magic Show (APIO24_show) | C++20 | 0 ms | 0 KiB |
#include "Alice.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> Alice() {
// #define int int64_t
long long X = setN(5000);
vector<pair<int, int>> res;
for (int64_t i = 1; i < 5000; i++) {
res.push_back({X%i + 1, i + 1});
}
return res;
}
#include "Bob.h"
#include <bits/stdc++.h>
using namespace std;
int gcd_r(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1, y = 0;
return a;
}
int g = gcd(b, a%b, x, y);
int xp = y;
int yp = x - y * (a / b);
x = xp, y = yp;
return g;
}
long long Bob(vector<pair<__int128_t, __int128_t>> v) {
while (v.size() >= 2) {
auto [r1, a1] = v.back();
v.pop_back();
auto [r2, a2] = v.back();
v.pop_back();
int gg = __gcd(a1, a2);
a1 /= gg;
a2 /= gg;
r1 %= a1;
r2 %= a2;
int x, y;
gg = gcd(a1, a2, x, y);
y *= -1;
x *= r2 - r1;
y *= r2 - r1;
v.push_back({a1 * x + r1, a1 * a2});
}
return v.back().first();
}
