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"
#define el '\n'
#define fi first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int N=1e5+11;
vector<pii> tree;
ll x, mod[N];
long long setN(ll n)
{
cin >> x;
return x;
}
//ll lcm(ll a, ll b)
//{
// return a*b/__gcd(a, b);
//}
std::vector<std::pair<int,int>> Alice()
{
// add your code here
// change below into your code
long long x = setN(5000);
for(int i=1; i<5000; i++) tree.push_back({x%i+1, i+1});
return tree;
}
//long long Bob(std::vector<std::pair<int,int>> V){
// add your code here
//
// change this into your code
// for(int i=1;i<=5000;i++) mod[i]=-1;
// for(auto x:V) mod[x.sc-1]=x.fi-1;
// ll lcmm=1, ans=0;
// for(int i=1;i<=5000;i++)
// {
// if(mod[i]==-1) continue;
// while(ans%i!=mod[i]) ans+=lcmm;
// lcmm=lcm(lcmm, i);
// }
// int ch=0;
// for(int i=1;i<=5000;i++)
// {
// if(mod[i]==-1) continue;
// if((x%i)!=mod[i]) ch=1;
// }
// if(ch==0) return ans;
// else return -1;
// return ans;
//}
//void sol()
//{
// Alice();
//// for(auto x:tree) cout << x.fi << ' ' << x.sc << el;
// cout << Bob(tree);
//}
//signed main()
//{
//// freopen("divisor.INP", "r", stdin);
//// freopen("divisor.OUT", "w", stdout);
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// int t=1;
// //cin >> t;
// while(t--)
// {
// sol();
// }
//}
#include<bits/stdc++.h>
#include "Bob.h"
#define el '\n'
#define fi first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int N=1e5+11;
vector<pii> tree;
ll x, mod[N];
//long long setN(int n)
//{
// cin >> x;
// return x;
//}
ll lcm(ll a, ll b)
{
return a*b/__gcd(a, b);
}
//std::vector<std::pair<int,int>> Alice()
//{
// // add your code here
//
// // change below into your code
// long long x = setN(5000);
//
// for(int i=1; i<5000; i++) tree.push_back({x%i+1, i+1});
// return tree;
//}
long long Bob(std::vector<std::pair<int,int>> V){
// add your code here
// change this into your code
for(int i=1;i<=5000;i++) mod[i]=-1;
for(auto x:V) mod[x.sc-1]=x.fi-1;
ll lcmm=1, ans=0;
for(int i=1;i<=5000;i++)
{
if(mod[i]==-1) continue;
while(ans%i!=mod[i]) ans+=lcmm;
lcmm=lcm(lcmm, i);
}
// int ch=0;
// for(int i=1;i<=5000;i++)
// {
// if(mod[i]==-1) continue;
// if((x%i)!=mod[i]) ch=1;
// }
// if(ch==0) return ans;
// else return -1;
return ans;
}
//void sol()
//{
// Alice();
//// for(auto x:tree) cout << x.fi << ' ' << x.sc << el;
// cout << Bob(tree);
//}
//signed main()
//{
//// freopen("divisor.INP", "r", stdin);
//// freopen("divisor.OUT", "w", stdout);
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// int t=1;
// //cin >> t;
// while(t--)
// {
// sol();
// }
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |