题目大意:给你$a,b(a,b\leqslant10^{10001})$,求出$\dfrac a b\equiv1\pmod{19260817}$,无解输出 Angry!
题解:在读入的时候取模,若$b=0$输出无解,否则正常的求逆就行了
卡点:无
C++ Code:
#include <cstdio> #include <cctype> const long long mod = 19260817; long long a, b; inline long long read() { long long x; char t = getchar(); while (isspace(t)) t = getchar(); for (x = t & 15, t = getchar(); isdigit(t); t = getchar()) x = (x * 10 + (t & 15)) % mod; return x; } void exgcd(long long a, long long b, long long &x, long long &y) { if (!b) x = 1, y = 0; else exgcd(b, a % b, y, x), y -= a / b * x; } inline long long INV(long long a) { long long x, y; exgcd(a, mod, x, y); if (x < 0) x += mod; return x; } int main() { a = read(), b = read(); if (!b) { puts("Angry!"); return 0; } printf("%lld\n", a * INV(b) % mod); return 0; }
原文:https://www.cnblogs.com/Memory-of-winter/p/9692412.html