用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#21342 | #1070. 脸盲的zzy和jwp | Wrong Answer | 25 | 30 ms | 356 K | C++ 17 / 942 B | 自动化82-郭筠陶 | 2020-02-05 15:23:09 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x, y, a, b, l;
ll exgcd(ll a, ll b, ll& x, ll& y);
int main() {
cin >> x >> a >> y >> b >> l;
if (b == a) {
if (x != y)
cout << -1;
else
cout << 0;
return 0;
}
if (b < a) {
swap(a, b);
swap(x, y);
}
ll p = b - a, q = ((x - y) + l) % l;
ll t, k;
int gcd = exgcd(p, l, t, k);
if (q % gcd != 0) {
cout << -1;
} else {
ll t0 = t * (q / gcd), q0 = (q / gcd);
t0 = (t0 % q0 + q0) % q0;
cout << t0;
}
}
ll exgcd(ll a, ll b, ll& x, ll& y) { //扩展欧几里得算法
if (b == 0) {
x = 1;
y = 0;
return a; //到达递归边界开始向上一层返回
}
int r = exgcd(b, a % b, x, y);
int temp = y; //把x y变成上一层的
y = x - (a / b) * y;
x = temp;
return r; //得到a b的最大公因数
}
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
-1
系统信息
Exited with return code 0
用户输出
-1
系统信息
Exited with return code 0