记录编号 |
571032 |
评测结果 |
AAAAAAAAAAAAAAAAAAAAA |
题目名称 |
[POJ 1061] 青蛙的约会 |
最终得分 |
100 |
用户昵称 |
lihaoze |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2022-05-04 19:02:41 |
内存使用 |
0.00 MiB |
显示代码纯文本
- #include <bits/stdc++.h>
- #define OPEN(_x) freopen(#_x".in", "r", stdin); freopen(#_x".out", "w", stdout)
- #define rep(_x, _y, _z) for (int _x = (_y); _x <= (_z); ++ _x)
- #define rep1(_x, _y, _z) for (int _x = (_y); _x < (_z); ++ _x)
- #define fi first
- #define se second
-
- using i64 = long long;
- using PII = std::pair<int, int>;
-
- i64 exgcd(i64 a, i64 b, i64 &x, i64 &y) {
- if (b == 0) { x = 1, y = 0; return a; }
- i64 d = exgcd(b, a % b, y, x);
- y -= x * (a / b);
- return d;
- }
-
- i64 x, y, m, n, L;
- i64 p, t;
-
- int main() {
- OPEN(poj_hama);
- std::ios::sync_with_stdio(false);
- std::cin.tie(nullptr);
- std::cin >> x >> y >> m >> n >> L;
- i64 d = exgcd(L, n - m, p, t);
- i64 q = L / d;
- if ((x - y) % d != 0) std::cout << "Impossible" << '\n';
- else {
- t *= (x - y) / d;
- t %= q;
- while (t < 0) {
- if (q < 0) t -= q;
- else t += q;
- }
- std::cout << t << '\n';
- }
- return 0;
- }