#include "Alice.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> > Alice(){
int64_t X = setN(5000);
vector<pair<int, int> > ans;
for (int i = 1; i < 5000; i++)
ans.emplace_back(X%i+1, i+1);
return ans;
}
#include "Bob.h"
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 1'000'000'000'000'000'000LL;
int64_t gcd(int64_t a, int64_t b) {
return b == 0 ? a : gcd(b, a%b);
}
int64_t lcm(int64_t a, int64_t b) {
int64_t t = gcd(a, b);
b /= t;
if ((INF+1) / b < a) return INF+1;
return a*b;
}
long long Bob(vector<pair<int,int>> V) {
int64_t ans = 0, LCC = 0;
for (auto [u, v] : V) {
if (u > v) swap(u, v);
int A = u-1, B = v-1;
if (LCC == 0) {
ans = A;
LCC = B;
continue;
}
while (ans % B != A) ans += LCC;
LCC = lcm(LCC, B);
if (LCC > INF) break;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |