用户输出
4
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#20476 | #1070. 脸盲的zzy和jwp | Accepted | 100 | 56 ms | 404 K | C++ 17 / 1.3 K | q3540555 | 2019-07-22 15:28:34 |
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define spause() system("pause")
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> prdd;
typedef map<int, int> mpdd;
const int dinf = 0x7fffffff;
const llong llinf = 0x7fffffffffffffff;
const int p = 998244353;
llong starttime;
llong x, a, y, b, l, dv, dx, ans, tp;
llong gcd(llong a, llong b) { return b ? gcd(b, a % b) : a; }
llong exgcd(llong a, llong b, llong &x, llong &y) {
if (!b) {
x = 1;
y = 0;
return a;
}
llong 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);
dv = a - b;
dx = y - x;
if (dv < 0) {
dv = -dv;
dx = -dx;
}
llong gcds = exgcd(dv, l, ans, tp);
if ((dx % gcds + gcds) % gcds != 0)
goto badend;
ans = dx / gcds * ans;
ans = (ans % (l / gcds) + l / gcds) % (l / gcds);
printf("%lld", ans);
// cout << "\nDebug Info: " << clock() - starttime << " ms passed!\n";
spause();
return 0;
badend:
printf("-1");
return 0;
}
用户输出
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