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 <bits/stdc++.h>
#include "Alice.h"
std::vector<std::pair<int, int>> Alice() {
long long x = setN(5000);
std::vector<std::pair<int, int>> result;
for (int i = 2; i <= 5000; ++i) {
result.emplace_back(i, (x % (i - 1)) + 1);
}
return result;
}
#include <bits/stdc++.h>
#include "Bob.h"
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long Bob(std::vector<std::pair<int, int>> V) {
long long base = std::max(V[0].first, V[0].second) - 1;
long long res = std::min(V[0].first, V[0].second) - 1;
for (auto [b, e]: V) {
if (b < e) std::swap(b, e);
b--;
e--;
if (gcd(b, base) == 1) {
for (long long i = 0;; ++i) {
if ((base * i + res) % b == e) {
long long nb = base * b;
long long nr = (base * i + res) % nb;
std::tie(base, res) = {nb, nr};
if (base >= 1000000000000000001ll) return res;
break;
}
}
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |