用户输出
4
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#10492 | #1070. 脸盲的zzy和jwp | Accepted | 100 | 57 ms | 348 K | C++ / 678 B | zz_ylolita | 2019-07-04 12:39:39 |
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long LL;
LL a, b, x, y, l, c;
LL d;
LL exgcd(LL a, LL b, LL& x, LL& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
} else {
LL d = exgcd(b, a % b, y, x);
y = y - a / b * x;
return d;
}
}
int main() {
scanf("%lld%lld%lld%lld%lld", &x, &a, &y, &b, &l);
a = ((a - b) % l + l) % l;
c = ((y - x) % l + l) % l;
x = y = 0;
d = exgcd(a, l, x, y);
// cout<<a<<' '<<l<<' '<<x<<' '<<y<<endl;
if (c % d)
printf("-1");
else {
// cout<<x<<endl;
x = c / d * x % (l / d);
if (x < 0)
x = (x + (l / d)) % (l / d);
printf("%lld\n", x);
}
}
用户输出
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