結果
問題 | No.882 約数倍数 |
ユーザー | mdstoy |
提出日時 | 2019-09-13 21:24:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 500 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 1,606 ms |
コンパイル使用メモリ | 172,564 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 03:55:48 |
合計ジャッジ時間 | 2,210 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i, m, n) for (int i = (m); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 1, (n) + 1) #define ALL(c) (c).begin(), (c).end() template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} const int MOD = 1000000007; const int INF = 1000000001; vector<ll> divisors(ll n) { vector<ll> v; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { v.push_back(i); if (i * i != n) { v.push_back(n / i); } } } return v; } int main() { int a, b; cin >> a >> b; vector<ll> d = divisors(a); sort(ALL(d)); int c = b; while (c <= a) { for (auto x : d) { if (c == x) { cout << "YES" << endl; return 0; } } c += b; } cout << "NO" << endl; }