test/yosupo/math/min_linear.test.cpp
依存するヘッダ(1)
-
$0\le x<n$ における $(ax+b)\bmod m$ の最小値を返す
lib/number_theory/min_linear.hpp
実装
// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/min_of_mod_of_linear
#include <iostream>
#include "number_theory/min_linear.hpp"
int main() {
int t;
std::cin >> t;
while (t--) {
int n, m, a, b;
std::cin >> n >> m >> a >> b;
std::cout << min_linear(n, m, a, b) << '\n';
}
return 0;
}