a / b % p = a * b-1 % p,又因为p是质数,根据费马小定理=> a * b-1 % p = a * bp-2 % p。
看数据范围,不想写高精,就改了一下快读。
1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 #include<algorithm> 5 #include<cstring> 6 #include<cstdlib> 7 #include<cctype> 8 #include<vector> 9 #include<stack> 10 #include<queue> 11 using namespace std; 12 #define enter puts("") 13 #define space putchar(' ') 14 #define Mem(a, x) memset(a, x, sizeof(a)) 15 #define rg register 16 typedef long long ll; 17 typedef double db; 18 const int INF = 0x3f3f3f3f; 19 const db eps = 1e-8; 20 const int mod = 19260817; 21 inline ll read() 22 { 23 ll ans = 0; 24 char ch = getchar(), last = ' '; 25 while(!isdigit(ch)) {last = ch; ch = getchar();} 26 while(isdigit(ch)) {ans = ans * 10 % mod + ch - '0'; ch = getchar();} 27 ans %= mod; 28 if(last == '-') ans = -ans; 29 return ans; 30 } 31 inline void write(ll x) 32 { 33 if(x < 0) x = -x, putchar('-'); 34 if(x >= 10) write(x / 10); 35 putchar(x % 10 + '0'); 36 } 37 38 ll quickpow(ll a, int b) 39 { 40 ll ret = 1; 41 while(b) 42 { 43 if(b & 1) ret = ret * a % mod; 44 a = a * a % mod; b >>= 1; 45 } 46 return ret; 47 } 48 49 int main() 50 { 51 ll a = read(), b = read(); 52 if(!b) {printf("Angry!\n"); return 0;} 53 ll ans = a * quickpow(b, mod - 2) % mod; 54 write(ans); enter; 55 }