#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
typedef __int64 LL;
LL gcd(LL a, LL b)
{
return b ? gcd(b, a%b) : a;
}
LL pow_mod(LL a, LL p, LL n)
{
LL ans = 1;
while(p)
{
if(p&1)
{
ans *= a;
ans %= n;
}
a *= a;
a %= n;
p >>= 1;
}
return ans;
}
void mod_gcd(LL a, LL b, LL& d, LL& x, LL& y)
{
if(!b)
{
d = a;
x = 1;
y = 0;
}
else
{
mod_gcd(b, a%b, d, y, x);
y -= ......
阅读全文