Submission #1184783

#TimeUsernameProblemLanguageResultExecution timeMemory
1184783anmattroi마술쇼 (APIO24_show)C++17
100 / 100
2 ms380 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...