はまやんはまやんはまやん

hamayanhamayan's blog

約数倍数 [yukicoder 882]

https://yukicoder.me/problems/no/882

解説

https://yukicoder.me/submissions/379418

条件を満たす整数は、Aの約数なので、[1,A]のどこかにある。
なので、これを全探索して、Aの約数であってBの倍数であるものがあれば、YES
そうでないならNO

int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    rep(x, 1, A + 1) if(A % x == 0 and x % B == 0) {
        cout << "YES" << endl;
        return;
    }
    cout << "NO" << endl;
}