This commit is contained in:
1 parent
64415e876b
commit
cd0c65ca4e
2 files changed
+71
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define int long long
|
||||
using namespace std;
|
||||
const int mod = 19260817;
|
||||
signed main() {
|
||||
auto read = [](int &x) {
|
||||
x = 0;
|
||||
char c = getchar();
|
||||
while (c < '0' || c > '9')
|
||||
c = getchar();
|
||||
while (c >= '0' && c <= '9')
|
||||
x = (x * 10 + c - '0') % mod, c = getchar();
|
||||
};
|
||||
auto qpow = [](int a, int b) {
|
||||
a %= mod;
|
||||
int ans = 1;
|
||||
while (b) {
|
||||
if (b & 1)
|
||||
ans = (ans * a) % mod;
|
||||
a = (a * a) % mod;
|
||||
b >>= 1;
|
||||
}
|
||||
return ans;
|
||||
};
|
||||
int a, b;
|
||||
read(a), read(b);
|
||||
if (a == 0 || b == 0)
|
||||
printf("Angry!\n");
|
||||
else
|
||||
printf("%lld\n", (a * qpow(b, mod - 2)) % mod);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
# P2613 【模板】有理数取余
|
||||
|
||||
## 题目描述
|
||||
|
||||
给出一个有理数 $c=\frac{a}{b}$,求 $c \bmod 19260817$ 的值。
|
||||
|
||||
这个值被定义为 $bx\equiv a\pmod{19260817}$ 的解。
|
||||
|
||||
## 输入格式
|
||||
|
||||
一共两行。
|
||||
|
||||
第一行,一个整数 $a$。
|
||||
第二行,一个整数 $b$。
|
||||
|
||||
## 输出格式
|
||||
|
||||
一个整数,代表求余后的结果。如果无解,输出 `Angry!`。
|
||||
|
||||
## 输入输出样例 #1
|
||||
|
||||
### 输入 #1
|
||||
|
||||
```
|
||||
233
|
||||
666
|
||||
|
||||
```
|
||||
|
||||
### 输出 #1
|
||||
|
||||
```
|
||||
18595654
|
||||
|
||||
```
|
||||
|
||||
## 说明/提示
|
||||
|
||||
对于所有数据,保证 $0\leq a \leq 10^{10001}$,$1 \leq b \leq 10^{10001}$,且 $a, b$ 不同时是 $19260817$ 的倍数。
|
||||
Reference in new issue
Block a user