test/aoj/NTL_1_E/main.test.cpp
Depends on
Code
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_E"
#include <iostream>
#include "Mylib/Number/extended_gcd.cpp"
namespace hl = haar_lib;
int main() {
int a, b;
std::cin >> a >> b;
int x, y;
std::tie(std::ignore, x, y) = hl::ext_gcd(a, b);
std::cout << x << " " << y << std::endl;
return 0;
}
#line 1 "test/aoj/NTL_1_E/main.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_E"
#include <iostream>
#line 2 "Mylib/Number/extended_gcd.cpp"
#include <tuple>
namespace haar_lib {
auto ext_gcd(int64_t a, int64_t b) -> std::tuple<
int64_t, // gcd
int64_t, // p
int64_t // q
> {
if (b == 0) return std::make_tuple(a, 1, 0);
const auto [d, q, p] = ext_gcd(b, (a + b) % b);
return std::make_tuple(d, p, q - a / b * p);
}
} // namespace haar_lib
#line 5 "test/aoj/NTL_1_E/main.test.cpp"
namespace hl = haar_lib;
int main() {
int a, b;
std::cin >> a >> b;
int x, y;
std::tie(std::ignore, x, y) = hl::ext_gcd(a, b);
std::cout << x << " " << y << std::endl;
return 0;
}
Back to top page