hiho week 279 register

Ended

Participants:46

Verdict:Accepted
Score:100 / 100
Submitted:2019-11-02 20:02:48

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
typedef long long LL;
inline LL extend_gcd(LL a,LL b,LL &x,LL &y)
{
    if(a == 0 && b == 0)
        return -1ll;
    if(b == 0)
    {
        x = 1ll;
        y = 0ll;
        return a;
    }
    LL d = extend_gcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
inline LL mod_reverse(LL a,LL n)
{
    LL x, y, d = extend_gcd(a, n, x, y);
    if(d == 1)
        return (x % n + n) % n;
    else
        return -1ll;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX