# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061783 | rainboy | Magic Show (APIO24_show) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Alice.h"
#include <utility>
#include <vector>
typedef pair<int, int> pi;
typedef vector<pi> vpi;
const int N = 5000;
vpi Alice() {
long long x = setN(N);
vpi ij;
for (int j = 1; j < N; j++) {
int i = x % j;
ij.push_back(make_pair(i + 1, j + 1));
}
return ij;
}
#include "Bob.h"
#include <utility>
#include <vector>
using namespace std;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
long long Bob(vpi ij) {
const long long M = 1000000000000000000;
int m;
long long md = 1, x = 0;
for (int h = 0; h < m && md <= M; h++) {
int i = ij[h].first - 1, j = ij[h].second - 1;
while (x % j != i)
x += md;
int k = 1;
while (md * k <= M && md * k % j != 0)
k++;
md *= k;
}
return x;
}