用户输出
4
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#22471 | #1070. 脸盲的zzy和jwp | Accepted | 100 | 36 ms | 360 K | C++ 17 / 704 B | Leohh | 2020-02-12 22:10:24 |
#include <iostream>
#include <stdio.h>
#include <string.h>
#define int long long
using namespace std;
int x, a, y, b, p;
void exgcd(int a, int b, int &x, int &y) {
if (!b) {
x = 1, y = 0;
return;
}
exgcd(b, a % b, y, x);
y -= a / b * x;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
signed main() {
scanf("%lld%lld%lld%lld%lld", &x, &a, &y, &b, &p);
int A = ((a - b) % p + p) % p, B = p, C = ((y - x) % p + p) % p;
int G = gcd(A, B);
if (C % G) {
printf("-1\n");
return 0;
}
int X, Y;
exgcd(A, B, X, Y);
int t = B / G;
printf("%lld\n", ((X * C / G) % t + t) % t);
}
用户输出
175111586
系统信息
Exited with return code 0
用户输出
91595156
系统信息
Exited with return code 0
用户输出
6586798
系统信息
Exited with return code 0
用户输出
83740797
系统信息
Exited with return code 0
用户输出
116043662
系统信息
Exited with return code 0
用户输出
42763932
系统信息
Exited with return code 0
用户输出
445951169
系统信息
Exited with return code 0
用户输出
169591840
系统信息
Exited with return code 0
用户输出
-1
系统信息
Exited with return code 0
用户输出
-1
系统信息
Exited with return code 0