# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19752 | Qwaz | 팔찌 (kriii4_V) | C++98 | 552 ms | 15032 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 <iostream>
#include <vector>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007LL;
// computes a * b mod n
inline ll times_mod(ll a, ll b, ll n)
{
return a * b % n;
}
// solves a*x + b*y = d = gcd(a, b)
// if d == 1, x is a modular inverse of a mod b
void extended_gcd(ll a, ll b, ll &d, ll &x, ll &y)
{
if(a < 0) {extended_gcd(-a, b, d, x, y); x *= -1; return;}
if(b < 0) {extended_gcd(a, -b, d, x, y); y *= -1; return;}
x = 0, y = 1;
ll lx = 1, ly = 0, frac, tmp;
while(b)
{
frac = a / b;
tmp = a; a = b; b = tmp % b;
tmp = x; x = lx - frac * x; lx = tmp;
tmp = y; y = ly - frac * y; ly = tmp;
}
x = lx; y = ly; d = a;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |