题意
给出一个有理数\(c=\frac{a}{b}\),求\(c \mod 19260817\)的值。
题解
在读入时先模一下,然后直接用逆元
代码
#include <cstdio>
const int mod = 19260817;
typedef long long ll;
int a, b;
char ch;
int read_int(int s = 0)
{
ch = getchar();
while (ch < '0' || ch > '9') ch = getchar();
for (s = ch - '0'; ch = getchar(), ch >= '0' && ch <= '9'; s = s * 10 % mod + ch - '0');
return s;
}
int _pow(int x, int y, int s = 1)
{
for (register int i = y; i; i >>= 1, x = (ll)x * x % mod)
if (i & 1)
s = (ll) s * x % mod;
return s;
}
int main()
{
a = read_int();
b = read_int();
if (!b) puts("Angry!");
else printf("%d\n", (int)((ll)a * _pow(b, mod - 2) % mod));
}