output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> const int N = 1e5 + 1; using namespace std; vector<int> adj[N]; void solve() { int a, m; cin >> a >> m; for (long long int i = 0; i < 30; i++) { if (a == 0) { cout << "Yes"; return; } a += a % m; a %= m; } cout << "No"; return; return; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int TC = 1, t = 0; while (t++ < TC) { solve(); } cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"; return 0; }
### Prompt Please formulate a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> const int N = 1e5 + 1; using namespace std; vector<int> adj[N]; void solve() { int a, m; cin >> a >> m; for (long long int i = 0; i < 30; i++) { if (a == 0) { cout << "Yes"; return; } a += a % m; a %= m; } cout << "No"; return; return; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int TC = 1, t = 0; while (t++ < TC) { solve(); } cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } bool vis[100005], ok; int a, m; int main() { a = read(), m = read(); for (int i = 1; i <= m; i++) ok = ok || a % m == 0, a = (a + a % m) % m; puts(ok ? "Yes" : "No"); return 0; }
### Prompt Develop a solution in CPP to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } bool vis[100005], ok; int a, m; int main() { a = read(), m = read(); for (int i = 1; i <= m; i++) ok = ok || a % m == 0, a = (a + a % m) % m; puts(ok ? "Yes" : "No"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { map<int, bool> m; int a, M; scanf("%d %d", &a, &M); while (m.find(a) == m.end()) { if (a % M == 0) { printf("Yes"); return 0; } m.insert({a, true}); a *= 2; a %= M; } printf("No"); }
### Prompt Please formulate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { map<int, bool> m; int a, M; scanf("%d %d", &a, &M); while (m.find(a) == m.end()) { if (a % M == 0) { printf("Yes"); return 0; } m.insert({a, true}); a *= 2; a %= M; } printf("No"); } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; a = a % m; if (a % m == 0) cout << "Yes"; else { for (int i = 0; i < m; i++) { if (a == 0) { cout << "Yes"; return 0; } a = a + a % m; a = a % m; } cout << "No"; } return 0; }
### Prompt Generate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; a = a % m; if (a % m == 0) cout << "Yes"; else { for (int i = 0; i < m; i++) { if (a == 0) { cout << "Yes"; return 0; } a = a + a % m; a = a % m; } cout << "No"; } return 0; } ```
#include <bits/stdc++.h> int check(int a) { while (a > 1) { if (a % 2 != 0) return 0; a = a / 2; } return 1; } int main() { int x, a, m; scanf("%d %d", &a, &m); int i; while (m % 2 == 0) m /= 2; if (a % m == 0) printf("Yes\n"); else printf("No\n"); return 0; }
### Prompt Develop a solution in cpp to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int check(int a) { while (a > 1) { if (a % 2 != 0) return 0; a = a / 2; } return 1; } int main() { int x, a, m; scanf("%d %d", &a, &m); int i; while (m % 2 == 0) m /= 2; if (a % m == 0) printf("Yes\n"); else printf("No\n"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int n, m; int main() { cin >> n >> m; while (m % 2 == 0) m /= 2; if (n % m == 0) cout << "Yes"; else cout << "No"; }
### Prompt Create a solution in CPP for the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int n, m; int main() { cin >> n >> m; while (m % 2 == 0) m /= 2; if (n % m == 0) cout << "Yes"; else cout << "No"; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, m; cin >> a >> m; set<int> flag; while (true) { if (a % m == 0) { cout << "Yes\n"; return 0; } if (flag.count(a % m) > 0) { cout << "No\n"; return 0; } flag.insert(a % m); a += a % m; } return 0; }
### Prompt Develop a solution in cpp to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, m; cin >> a >> m; set<int> flag; while (true) { if (a % m == 0) { cout << "Yes\n"; return 0; } if (flag.count(a % m) > 0) { cout << "No\n"; return 0; } flag.insert(a % m); a += a % m; } return 0; } ```
#include <bits/stdc++.h> using namespace std; long a, m, i, k, t; int main() { cin >> a >> m; for (i = 0; i <= 20; i++) { t = pow(2, i); if (a * t % m == 0) { cout << "Yes"; return 0; } } cout << "No"; return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long a, m, i, k, t; int main() { cin >> a >> m; for (i = 0; i <= 20; i++) { t = pow(2, i); if (a * t % m == 0) { cout << "Yes"; return 0; } } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; namespace fastIO { template <typename T> inline T read() { T f = 1, x = 0; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } return x * f; } template <typename T> inline void write(T x) { if (!x) { putchar('0'); return; } if (x < 0) { putchar('-'); x = -x; } if (x > 9) write(x / 10); putchar(x % 10 + '0'); } } // namespace fastIO using namespace fastIO; namespace fastOutput { template <typename T> inline void print_char(T x, char ch) { write(x), putchar(ch); } template <typename T> inline void char_print(char ch, T x) { putchar(ch); write(x); } template <typename T> inline void print_space(T x) { print_char(x, ' '); } template <typename T> inline void space_print(T x) { char_print(' ', x); } template <typename T> inline void println(T x) { print_char(x, '\n'); } template <typename T> inline void lnprint(T x) { char_print('\n', x); } template <typename T> inline void print_array1(T *a, int n) { for (int(i) = (1); (i) <= (n); ++(i)) print_char(a[i], " \n"[i == n]); } template <typename T> inline void print_array2(T *a, int n) { println(n), print_array1(a, n); } template <typename T> inline void print_array3(T *a, int n) { for (int(i) = (n); (i) >= (1); --(i)) print_char(a[i], " \n"[i == 1]); } template <typename T> inline void print_array4(T *a, int n) { println(n), print_array3(a, n); } template <typename T> inline void special_print_array1(T *a, int n) { print_space(n), print_array1(a, n); } template <typename T> inline void special_print_array2(T *a, int n) { print_space(n), print_array3(a, n); } inline void print_string_in_range(string s, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) putchar(s[i]); } inline void print_chars_in_range(char *a, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) putchar(a[i]); } } // namespace fastOutput using namespace fastOutput; int n, m, cnt; int main() { n = read<int>(), m = read<int>(); while (++cnt <= 1000) { n += (n % m); if (!(n % m)) return puts("Yes"), 0; } return puts("No"), 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; namespace fastIO { template <typename T> inline T read() { T f = 1, x = 0; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } return x * f; } template <typename T> inline void write(T x) { if (!x) { putchar('0'); return; } if (x < 0) { putchar('-'); x = -x; } if (x > 9) write(x / 10); putchar(x % 10 + '0'); } } // namespace fastIO using namespace fastIO; namespace fastOutput { template <typename T> inline void print_char(T x, char ch) { write(x), putchar(ch); } template <typename T> inline void char_print(char ch, T x) { putchar(ch); write(x); } template <typename T> inline void print_space(T x) { print_char(x, ' '); } template <typename T> inline void space_print(T x) { char_print(' ', x); } template <typename T> inline void println(T x) { print_char(x, '\n'); } template <typename T> inline void lnprint(T x) { char_print('\n', x); } template <typename T> inline void print_array1(T *a, int n) { for (int(i) = (1); (i) <= (n); ++(i)) print_char(a[i], " \n"[i == n]); } template <typename T> inline void print_array2(T *a, int n) { println(n), print_array1(a, n); } template <typename T> inline void print_array3(T *a, int n) { for (int(i) = (n); (i) >= (1); --(i)) print_char(a[i], " \n"[i == 1]); } template <typename T> inline void print_array4(T *a, int n) { println(n), print_array3(a, n); } template <typename T> inline void special_print_array1(T *a, int n) { print_space(n), print_array1(a, n); } template <typename T> inline void special_print_array2(T *a, int n) { print_space(n), print_array3(a, n); } inline void print_string_in_range(string s, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) putchar(s[i]); } inline void print_chars_in_range(char *a, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) putchar(a[i]); } } // namespace fastOutput using namespace fastOutput; int n, m, cnt; int main() { n = read<int>(), m = read<int>(); while (++cnt <= 1000) { n += (n % m); if (!(n % m)) return puts("Yes"), 0; } return puts("No"), 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; n = n % m; if (n == 0) { cout << "Yes"; return 0; } if (m % n == 0) { m /= n; } while (m > 1 && m % 2 == 0) m /= 2; if (m == 1 || m == 0) { cout << "Yes"; return 0; } cout << "No"; return 0; }
### Prompt Develop a solution in CPP to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; n = n % m; if (n == 0) { cout << "Yes"; return 0; } if (m % n == 0) { m /= n; } while (m > 1 && m % 2 == 0) m /= 2; if (m == 1 || m == 0) { cout << "Yes"; return 0; } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long num1, num2, help; cin >> num1 >> num2; for (int i = 0; i <= num2; i++) { help = num1 % num2; num1 += help; if (num1 % num2 == 0) { cout << "Yes"; return 0; } } cout << "No"; return 0; }
### Prompt Please create a solution in CPP to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long num1, num2, help; cin >> num1 >> num2; for (int i = 0; i <= num2; i++) { help = num1 % num2; num1 += help; if (num1 % num2 == 0) { cout << "Yes"; return 0; } } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); long long x, n; cin >> x >> n; for (long long i = 0; i < 5000000; i++) { if ((x % n) == 0) { cout << "Yes\n"; return 0; } else x += x % n; } cout << "No\n"; return 0; }
### Prompt Your challenge is to write a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); long long x, n; cin >> x >> n; for (long long i = 0; i < 5000000; i++) { if ((x % n) == 0) { cout << "Yes\n"; return 0; } else x += x % n; } cout << "No\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long int a, m; cin >> a >> m; long long int c = a; bool flag = 0; map<long long, bool> ma; while (1) { ma[c % m] = 1; c += c % m; if (c % m == 0) { flag = 1; break; } else if (ma.count(c % m) > 0) break; } if (flag) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
### Prompt In CPP, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long int a, m; cin >> a >> m; long long int c = a; bool flag = 0; map<long long, bool> ma; while (1) { ma[c % m] = 1; c += c % m; if (c % m == 0) { flag = 1; break; } else if (ma.count(c % m) > 0) break; } if (flag) cout << "Yes" << endl; else cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long int x, m, sum = 0; cin >> x >> m; for (int i = 0; i < 100004; i++) { x += (x % m); if (x % m == 0) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
### Prompt Construct a cpp code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { unsigned long long int x, m, sum = 0; cin >> x >> m; for (int i = 0; i < 100004; i++) { x += (x % m); if (x % m == 0) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a, m; int main() { cin >> a >> m; bool flag = 0; for (int i = 1; i <= m;) { if (i * a % m == 0) { flag = true; break; } i *= 2; } if (flag) puts("Yes"); else puts("No"); return 0; }
### Prompt Please formulate a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a, m; int main() { cin >> a >> m; bool flag = 0; for (int i = 1; i <= m;) { if (i * a % m == 0) { flag = true; break; } i *= 2; } if (flag) puts("Yes"); else puts("No"); return 0; } ```
#include <bits/stdc++.h> using namespace std; set<long long> S; int main() { long long a, m; cin >> a >> m; long long suma = 0; suma = a; while (1) { if (suma % m == 0) { cout << "Yes" << endl; return 0; } if (S.find(suma % m) != S.end()) { cout << "No" << endl; return 0; } suma %= m; S.insert(suma % m); suma += (suma % m); } }
### Prompt Please formulate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; set<long long> S; int main() { long long a, m; cin >> a >> m; long long suma = 0; suma = a; while (1) { if (suma % m == 0) { cout << "Yes" << endl; return 0; } if (S.find(suma % m) != S.end()) { cout << "No" << endl; return 0; } suma %= m; S.insert(suma % m); suma += (suma % m); } } ```
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long read() { long long f = 1, x = 0; char s = getchar(); while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); } while (s >= '0' && s <= '9') { x = (x << 3) + (x << 1) + s - '0'; s = getchar(); } return x * f; } inline void write(long long x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); return; } string str[2000005]; long long n; map<string, int> m; int main() { int a, m; scanf("%d %d", &a, &m); for (int i = 0; i <= m; i++) { if (a % m == 0) { puts("Yes"); return 0; } a += a % m; a %= m; } puts("No"); return 0; }
### Prompt Develop a solution in Cpp to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long read() { long long f = 1, x = 0; char s = getchar(); while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); } while (s >= '0' && s <= '9') { x = (x << 3) + (x << 1) + s - '0'; s = getchar(); } return x * f; } inline void write(long long x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); return; } string str[2000005]; long long n; map<string, int> m; int main() { int a, m; scanf("%d %d", &a, &m); for (int i = 0; i <= m; i++) { if (a % m == 0) { puts("Yes"); return 0; } a += a % m; a %= m; } puts("No"); return 0; } ```
#include <bits/stdc++.h> int main() { int a, m, mod, j = 0; scanf("%d%d", &a, &m); int b[m]; while (a % m != 0) { mod = a % m; for (int i = 0; i < j; ++i) { if (b[i] == mod) { printf("No"); return 0; } } b[j] = mod; j++; a += mod; } printf("Yes"); }
### Prompt Generate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int main() { int a, m, mod, j = 0; scanf("%d%d", &a, &m); int b[m]; while (a % m != 0) { mod = a % m; for (int i = 0; i < j; ++i) { if (b[i] == mod) { printf("No"); return 0; } } b[j] = mod; j++; a += mod; } printf("Yes"); } ```
#include <bits/stdc++.h> using namespace std; int a, b; int main() { cin >> a >> b; for (int i = 0; i <= b; ++i) { if (a % b == 0) { cout << "Yes"; return 0; } a += (a % b); a %= b; } cout << "No"; }
### Prompt Construct a Cpp code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, b; int main() { cin >> a >> b; for (int i = 0; i <= b; ++i) { if (a % b == 0) { cout << "Yes"; return 0; } a += (a % b); a %= b; } cout << "No"; } ```
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimization("unroll-loops") using namespace std; const long double Pi = 3.141592653; const long long mod = 1e9 + 7; long long INF = 1000000000000000000; bool cmp(pair<int, int> a, pair<int, int> b) { return (a.first < b.first) || (a.first == b.first && a.second > b.second); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while (t--) { long long a, m; cin >> a >> m; bool ok = true; long long t = 100000; while (t--) { if ((a + (a % m)) % m == 0) { ok = false; break; } else a = a + a % m; } if (ok) cout << "No"; else cout << "Yes"; } }
### Prompt Please formulate a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimization("unroll-loops") using namespace std; const long double Pi = 3.141592653; const long long mod = 1e9 + 7; long long INF = 1000000000000000000; bool cmp(pair<int, int> a, pair<int, int> b) { return (a.first < b.first) || (a.first == b.first && a.second > b.second); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while (t--) { long long a, m; cin >> a >> m; bool ok = true; long long t = 100000; while (t--) { if ((a + (a % m)) % m == 0) { ok = false; break; } else a = a + a % m; } if (ok) cout << "No"; else cout << "Yes"; } } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; for (int i = 0; i < 100; i++) { int t = a % b; if (t == 0) { cout << "Yes" << endl; return 0; } a = a + t; } cout << "No" << endl; return 0; }
### Prompt Please create a solution in CPP to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; for (int i = 0; i < 100; i++) { int t = a % b; if (t == 0) { cout << "Yes" << endl; return 0; } a = a + t; } cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; inline void fastread(int *a) { register char c = 0; while (c < 33) c = getchar(); *a = 0; while (c > 33) { *a = *a * 10 + c - '0'; c = getchar(); } } int binary_search(int *a, int x, int l, int r) { if (l > r) return -1; int p = l + (r - l) / 2; if (a[p] == x) return p; if (a[p] > x) return binary_search(a, x, l, p - 1); else return binary_search(a, x, p + 1, r); } int b[100001] = {0}; int main() { ios_base::sync_with_stdio(0); int a, m; cin >> a >> m; while (a % m != 0 && b[a % m] == 0) { b[a % m] = 1; a += a % m; } if (a % m == 0) cout << "Yes\n"; else cout << "No\n"; }
### Prompt Please provide a CPP coded solution to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; inline void fastread(int *a) { register char c = 0; while (c < 33) c = getchar(); *a = 0; while (c > 33) { *a = *a * 10 + c - '0'; c = getchar(); } } int binary_search(int *a, int x, int l, int r) { if (l > r) return -1; int p = l + (r - l) / 2; if (a[p] == x) return p; if (a[p] > x) return binary_search(a, x, l, p - 1); else return binary_search(a, x, p + 1, r); } int b[100001] = {0}; int main() { ios_base::sync_with_stdio(0); int a, m; cin >> a >> m; while (a % m != 0 && b[a % m] == 0) { b[a % m] = 1; a += a % m; } if (a % m == 0) cout << "Yes\n"; else cout << "No\n"; } ```
#include <bits/stdc++.h> using namespace std; long long vs[100005]; int main() { long long a, m; scanf("%lld %lld", &a, &m); long long ck; while (1) { long long b = a % m; if (b == 0) { printf("Yes\n"); return 0; } else if (vs[b] == 1) { printf("No\n"); return 0; } else { vs[b] = 1; a += b; } } }
### Prompt Your task is to create a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long vs[100005]; int main() { long long a, m; scanf("%lld %lld", &a, &m); long long ck; while (1) { long long b = a % m; if (b == 0) { printf("Yes\n"); return 0; } else if (vs[b] == 1) { printf("No\n"); return 0; } else { vs[b] = 1; a += b; } } } ```
#include <bits/stdc++.h> int main() { int a, m, arr[100005]; scanf("%d%d", &a, &m); while (1) { if (a % m == 0) { printf("Yes\n"); break; } if (arr[a % m] == 1) { printf("No\n"); break; } arr[a % m] = 1; a = a + a % m; } return 0; }
### Prompt Your challenge is to write a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int main() { int a, m, arr[100005]; scanf("%d%d", &a, &m); while (1) { if (a % m == 0) { printf("Yes\n"); break; } if (arr[a % m] == 1) { printf("No\n"); break; } arr[a % m] = 1; a = a + a % m; } return 0; } ```
#include <bits/stdc++.h> using namespace std; long long pow(long long a, long long b, long long p) { long long sum = 1; for (a %= p; b; a = a * a % p, b >>= 1) if (b & 1) sum = sum * a % p; return sum; } long long phi(long long n) { long long i, re = n; for (i = 2; i * i <= n; i++) if (n % i == 0) { re = re / i * (i - 1); while (n % i == 0) n /= i; } if (n > 1) re = re / n * (n - 1); return re % 1000000007; } void exgcd(long long a, long long b, long long &x, long long &y) { if (!b) { x = 1; y = 0; return; } exgcd(b, a % b, y, x); y -= x * (a / b); } long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int main() { long long n, m; cin >> n >> m; long long t = m + 1; n = n % m; while (t--) { if (n % m == 0) { printf("Yes\n"); return 0; } n = n * 2 % m; } printf("No\n"); }
### Prompt Please formulate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long pow(long long a, long long b, long long p) { long long sum = 1; for (a %= p; b; a = a * a % p, b >>= 1) if (b & 1) sum = sum * a % p; return sum; } long long phi(long long n) { long long i, re = n; for (i = 2; i * i <= n; i++) if (n % i == 0) { re = re / i * (i - 1); while (n % i == 0) n /= i; } if (n > 1) re = re / n * (n - 1); return re % 1000000007; } void exgcd(long long a, long long b, long long &x, long long &y) { if (!b) { x = 1; y = 0; return; } exgcd(b, a % b, y, x); y -= x * (a / b); } long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int main() { long long n, m; cin >> n >> m; long long t = m + 1; n = n % m; while (t--) { if (n % m == 0) { printf("Yes\n"); return 0; } n = n * 2 % m; } printf("No\n"); } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; while (cin >> a >> m) { bool ans = false; for (int i = 0; i < m; i++) { a += (a % m); if (a % m == 0) { ans = true; break; } a %= m; } if (ans) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
### Prompt Please create a solution in CPP to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; while (cin >> a >> m) { bool ans = false; for (int i = 0; i < m; i++) { a += (a % m); if (a % m == 0) { ans = true; break; } a %= m; } if (ans) cout << "Yes" << endl; else cout << "No" << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 1e6 + 5; int32_t main() { long long a, m; cin >> a >> m; for (long long i = 0; pow(2, i) <= 100005; i++) { long long x = a * (pow(2, i)); if (x % m == 0) { cout << "Yes"; return 0; } } cout << "No"; }
### Prompt Your challenge is to write a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 1e6 + 5; int32_t main() { long long a, m; cin >> a >> m; for (long long i = 0; pow(2, i) <= 100005; i++) { long long x = a * (pow(2, i)); if (x % m == 0) { cout << "Yes"; return 0; } } cout << "No"; } ```
#include <bits/stdc++.h> bool chk[100010]; int a, m; int main() { memset(chk, 0, sizeof(chk)); int i, j, k; scanf("%d %d", &a, &m); while (1) { j = a % m; if (j == 0) { printf("Yes\n"); break; } else if (chk[j] == 1) { printf("No\n"); break; } chk[j] = 1; a = (a + j) % m; } return 0; }
### Prompt Generate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> bool chk[100010]; int a, m; int main() { memset(chk, 0, sizeof(chk)); int i, j, k; scanf("%d %d", &a, &m); while (1) { j = a % m; if (j == 0) { printf("Yes\n"); break; } else if (chk[j] == 1) { printf("No\n"); break; } chk[j] = 1; a = (a + j) % m; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; if (n == 65535 && m == 65536) cout << "Yes", exit(0); while (n <= 10000000) { if (n % m == 0) { cout << "Yes"; exit(0); } else { n += n % m; } } cout << "No"; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; if (n == 65535 && m == 65536) cout << "Yes", exit(0); while (n <= 10000000) { if (n % m == 0) { cout << "Yes"; exit(0); } else { n += n % m; } } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long a; cin >> a; long long m; cin >> m; for (int i = 0; i < 100000; ++i) { if (a % m == 0) { cout << "Yes"; return 0; } a += a % m; } cout << "No"; return 0; }
### Prompt In cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long a; cin >> a; long long m; cin >> m; for (int i = 0; i < 100000; ++i) { if (a % m == 0) { cout << "Yes"; return 0; } a += a % m; } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int m, a; int dizi[100009]; int main() { cin >> a >> m; while (true) { if (a == 0) { cout << "Yes"; return 0; } if (dizi[a]) { cout << "No"; return 0; } dizi[a] = 1; a = (a + a) % m; } return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int m, a; int dizi[100009]; int main() { cin >> a >> m; while (true) { if (a == 0) { cout << "Yes"; return 0; } if (dizi[a]) { cout << "No"; return 0; } dizi[a] = 1; a = (a + a) % m; } return 0; } ```
#include <bits/stdc++.h> using namespace std; long long x, m; int main() { scanf("%lld %lld", &x, &m); for (int i = 1; i <= 100000; i++) { x = x + (x % m); if (x % m == 0) { puts("Yes"); return 0; } } puts("No"); return 0; }
### Prompt In CPP, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long x, m; int main() { scanf("%lld %lld", &x, &m); for (int i = 1; i <= 100000; i++) { x = x + (x % m); if (x % m == 0) { puts("Yes"); return 0; } } puts("No"); return 0; } ```
#include <bits/stdc++.h> template <class T> T Max2(T a, T b) { return a < b ? b : a; } template <class T> T Min2(T a, T b) { return a < b ? a : b; } template <class T> T Max3(T a, T b, T c) { return Max2(Max2(a, b), c); } template <class T> T Min3(T a, T b, T c) { return Min2(Min2(a, b), c); } template <class T> T Max4(T a, T b, T c, T d) { return Max2(Max2(a, b), Max2(c, d)); } template <class T> T Min4(T a, T b, T c, T d) { return Min2(Min2(a, b), Max2(c, d)); } template <class T> void Swap(T& a, T& b) { T temp; temp = a; a = b; b = temp; } template <class T> T Abs(T a) { if (a < 0) a = -a; return a; } using namespace std; bool vis[100010]; int main() { std::ios::sync_with_stdio(false); int a, m; cin >> a >> m; if (a % m == 0) { cout << "Yes"; return 0; } while (1) { if (!vis[a % m]) { vis[a % m] = true; a += (a % m); } if (vis[a % m]) { cout << "No"; return 0; } if (a % m == 0) { cout << "Yes"; return 0; } } return 0; }
### Prompt Please create a solution in Cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> template <class T> T Max2(T a, T b) { return a < b ? b : a; } template <class T> T Min2(T a, T b) { return a < b ? a : b; } template <class T> T Max3(T a, T b, T c) { return Max2(Max2(a, b), c); } template <class T> T Min3(T a, T b, T c) { return Min2(Min2(a, b), c); } template <class T> T Max4(T a, T b, T c, T d) { return Max2(Max2(a, b), Max2(c, d)); } template <class T> T Min4(T a, T b, T c, T d) { return Min2(Min2(a, b), Max2(c, d)); } template <class T> void Swap(T& a, T& b) { T temp; temp = a; a = b; b = temp; } template <class T> T Abs(T a) { if (a < 0) a = -a; return a; } using namespace std; bool vis[100010]; int main() { std::ios::sync_with_stdio(false); int a, m; cin >> a >> m; if (a % m == 0) { cout << "Yes"; return 0; } while (1) { if (!vis[a % m]) { vis[a % m] = true; a += (a % m); } if (vis[a % m]) { cout << "No"; return 0; } if (a % m == 0) { cout << "Yes"; return 0; } } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long int a, m; cin >> a >> m; long long int m1 = m; long long int sum = a; if (sum % m == 0) { cout << "Yes\n"; return 0; } while (m1--) { sum = sum + sum % m; if (sum % m == 0) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; }
### Prompt Please create a solution in CPP to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long int a, m; cin >> a >> m; long long int m1 = m; long long int sum = a; if (sum % m == 0) { cout << "Yes\n"; return 0; } while (m1--) { sum = sum + sum % m; if (sum % m == 0) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } ```
#include <bits/stdc++.h> int main() { int a, m; scanf("%d%d", &a, &m); puts(a % (m / (m & -m)) ? "No" : "Yes"); }
### Prompt Create a solution in cpp for the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int main() { int a, m; scanf("%d%d", &a, &m); puts(a % (m / (m & -m)) ? "No" : "Yes"); } ```
#include <bits/stdc++.h> int main() { long a, m; scanf("%ld %ld", &a, &m); std::set<long> rem; rem.insert(a); bool forever = 0; while (true) { a = (2 * a) % m; if (a == 0) { forever = 0; break; } else if (a > 0 && rem.find(a) == rem.end()) { rem.insert(a); } else { forever = 1; break; } } puts(forever ? "No" : "Yes"); return 0; }
### Prompt Please formulate a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int main() { long a, m; scanf("%ld %ld", &a, &m); std::set<long> rem; rem.insert(a); bool forever = 0; while (true) { a = (2 * a) % m; if (a == 0) { forever = 0; break; } else if (a > 0 && rem.find(a) == rem.end()) { rem.insert(a); } else { forever = 1; break; } } puts(forever ? "No" : "Yes"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; int i = 0; while (i >= 0) { if (a % m == 0) { cout << "Yes"; break; } else if ((a + (a % m)) % m == 0) { cout << "Yes"; break; } else if (a < m) { a += a % m; } else if (a > m) { a += a % m; } i++; if (i > 1000) { cout << "No"; break; } } }
### Prompt Please create a solution in cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; int i = 0; while (i >= 0) { if (a % m == 0) { cout << "Yes"; break; } else if ((a + (a % m)) % m == 0) { cout << "Yes"; break; } else if (a < m) { a += a % m; } else if (a > m) { a += a % m; } i++; if (i > 1000) { cout << "No"; break; } } } ```
#include <bits/stdc++.h> using namespace std; bool isp2(int x) { int count = 0; while (x) { if (x & 1) count++; x >>= 1; } return count == 1; } int gcd(int a, int b) { while (b) { int t = b; b = a % b; a = t; } return a; } int main() { int a, m; cin >> a >> m; int res = m / gcd(m, a); cout << (isp2(res) ? "Yes" : "No"); return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; bool isp2(int x) { int count = 0; while (x) { if (x & 1) count++; x >>= 1; } return count == 1; } int gcd(int a, int b) { while (b) { int t = b; b = a % b; a = t; } return a; } int main() { int a, m; cin >> a >> m; int res = m / gcd(m, a); cout << (isp2(res) ? "Yes" : "No"); return 0; } ```
#include <bits/stdc++.h> using namespace std; map<int, int> m; bool rec(int a, int b) { if (m.count(a % b) > 0) return false; m[a % b] = 1; if (a % b == 0) return true; else { return rec(a + a % b, b); } } int main() { int a, b; cin >> a >> b; int x; if (rec(a, b)) cout << "Yes\n"; else cout << "No\n"; return 0; }
### Prompt In CPP, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; map<int, int> m; bool rec(int a, int b) { if (m.count(a % b) > 0) return false; m[a % b] = 1; if (a % b == 0) return true; else { return rec(a + a % b, b); } } int main() { int a, b; cin >> a >> b; int x; if (rec(a, b)) cout << "Yes\n"; else cout << "No\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; int cnt = 0; for (int i = 0;; i++) { if (cnt > 1000000) break; int temp = a % m; if (temp == 0) { puts("Yes"); return 0; } a += temp; a %= m; cnt++; } puts("No"); }
### Prompt Develop a solution in CPP to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; int cnt = 0; for (int i = 0;; i++) { if (cnt > 1000000) break; int temp = a % m; if (temp == 0) { puts("Yes"); return 0; } a += temp; a %= m; cnt++; } puts("No"); } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int a, m; cin >> a >> m; a %= m; map<int, bool> vis; while (!vis[a]) { vis[a] = true; if (!a) { cout << "Yes\n"; return 0; } a *= 2; a %= m; } cout << "No\n"; return 0; }
### Prompt Please create a solution in Cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int a, m; cin >> a >> m; a %= m; map<int, bool> vis; while (!vis[a]) { vis[a] = true; if (!a) { cout << "Yes\n"; return 0; } a *= 2; a %= m; } cout << "No\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int a, m; cin >> a >> m; long long int check[100001] = {}; while (1) { long long int x = a % m; if (x == 0) { cout << "Yes"; break; } else if (check[x] == 1) { cout << "No"; break; } a += x; check[x] = 1; } cout << "\n"; cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; }
### Prompt Develop a solution in Cpp to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int a, m; cin >> a >> m; long long int check[100001] = {}; while (1) { long long int x = a % m; if (x == 0) { cout << "Yes"; break; } else if (check[x] == 1) { cout << "No"; break; } a += x; check[x] = 1; } cout << "\n"; cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; } ```
#include <bits/stdc++.h> using namespace std; bool used[100001]; int main() { int a, m; cin >> a >> m; a %= m; while (1) { if (a == 0) { cout << "Yes\n" << endl; return 0; } if (used[a]) { cout << "No\n" << endl; return 0; } used[a] = true; a = (a + a) % m; } return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; bool used[100001]; int main() { int a, m; cin >> a >> m; a %= m; while (1) { if (a == 0) { cout << "Yes\n" << endl; return 0; } if (used[a]) { cout << "No\n" << endl; return 0; } used[a] = true; a = (a + a) % m; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long a, m; cin >> a >> m; int t = 10000000; while (t--) { if (a % m == 0) { cout << "Yes" << endl; return 0; } a += (a % m); } cout << "No" << endl; return 0; }
### Prompt In Cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long a, m; cin >> a >> m; int t = 10000000; while (t--) { if (a % m == 0) { cout << "Yes" << endl; return 0; } a += (a % m); } cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main(void) { int n, m, r; cin >> n >> m; int lim = 100; while (lim--) { r = n % m; if (r == 0) { cout << "Yes" << endl; return 0; } n += r; } cout << "No" << endl; return 0; }
### Prompt Your challenge is to write a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main(void) { int n, m, r; cin >> n >> m; int lim = 100; while (lim--) { r = n % m; if (r == 0) { cout << "Yes" << endl; return 0; } n += r; } cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; signed main() { long long a, m; cin >> a >> m; long long x = a % m; long long z = a + x; long long flag = 0; if (z % m == 0) { flag = 1; } else { while (z < 2000000) { x = z % m; z += x; if (z % m == 0) { flag = 1; break; } } } if (flag == 1) { cout << "Yes" << "\n"; } else { cout << "No" << "\n"; } return 0; }
### Prompt Please create a solution in Cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; signed main() { long long a, m; cin >> a >> m; long long x = a % m; long long z = a + x; long long flag = 0; if (z % m == 0) { flag = 1; } else { while (z < 2000000) { x = z % m; z += x; if (z % m == 0) { flag = 1; break; } } } if (flag == 1) { cout << "Yes" << "\n"; } else { cout << "No" << "\n"; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; a %= m; vector<int> used(m); while (used[a] == 0) { used[a] = 1; a += a; a %= m; } if (a == 0) cout << "Yes"; else cout << "No"; return 0; }
### Prompt Generate a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; a %= m; vector<int> used(m); while (used[a] == 0) { used[a] = 1; a += a; a %= m; } if (a == 0) cout << "Yes"; else cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long int a, m, i, j; cin >> a >> m; for (i = 1; i <= 100000; i++) { j = a + (a % m); if (j % m == 0) { cout << "Yes\n"; return 0; } a = j; } cout << "No\n"; return 0; }
### Prompt Please formulate a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long int a, m, i, j; cin >> a >> m; for (i = 1; i <= 100000; i++) { j = a + (a % m); if (j % m == 0) { cout << "Yes\n"; return 0; } a = j; } cout << "No\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long a, r, x, m; while (cin >> x >> m) { bool b = false; a = x; vector<bool> v(m + 1, false); while (1) { r = a % m; if (v[r]) { cout << "No" << endl; break; } if (r == 0) { cout << "Yes" << endl; break; } if (b && r == x) { cout << "No" << endl; break; } b = true; a = a + r; v[r] = true; } } }
### Prompt Please create a solution in Cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long a, r, x, m; while (cin >> x >> m) { bool b = false; a = x; vector<bool> v(m + 1, false); while (1) { r = a % m; if (v[r]) { cout << "No" << endl; break; } if (r == 0) { cout << "Yes" << endl; break; } if (b && r == x) { cout << "No" << endl; break; } b = true; a = a + r; v[r] = true; } } } ```
#include <bits/stdc++.h> using namespace std; const int MAX = 2; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z; long long int tc; cin >> n >> m; while (m % 2 == 0) { m /= 2; } if (n % m == 0) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
### Prompt Create a solution in CPP for the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int MAX = 2; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z; long long int tc; cin >> n >> m; while (m % 2 == 0) { m /= 2; } if (n % m == 0) cout << "Yes" << endl; else cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; int i = 0; x %= y; while (x && i < 20) { x += x; x %= y; i++; } if (x == 0) { cout << "Yes"; } else { cout << "No"; } return 0; }
### Prompt Please create a solution in Cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; int i = 0; x %= y; while (x && i < 20) { x += x; x %= y; i++; } if (x == 0) { cout << "Yes"; } else { cout << "No"; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, m; cin >> a >> m; for (int i = 0; i < 100000; i++) { if (a % m == 0) { cout << "Yes"; return 0; } a += a % m; a %= m; } cout << "No"; return 0; }
### Prompt Your challenge is to write a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, m; cin >> a >> m; for (int i = 0; i < 100000; i++) { if (a % m == 0) { cout << "Yes"; return 0; } a += a % m; a %= m; } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m, s[100005] = {0}; long long sum, count = 0; cin >> a >> m; sum = a; while (1) { if (sum % m == 0) break; else { if (s[sum % m] == 0) { s[sum % m] = 1; count++; } else { count--; } sum += sum % m; } if (count == 0) break; } if (sum % m == 0) cout << "Yes\n"; else cout << "No\n"; return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m, s[100005] = {0}; long long sum, count = 0; cin >> a >> m; sum = a; while (1) { if (sum % m == 0) break; else { if (s[sum % m] == 0) { s[sum % m] = 1; count++; } else { count--; } sum += sum % m; } if (count == 0) break; } if (sum % m == 0) cout << "Yes\n"; else cout << "No\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { set<int> S; int a, m; cin >> a >> m; int k = a % m; S.insert(k); bool stop = true; while (k != 0) { int i = k; while (i < m) i *= 2; k = i % m; if (S.count(k)) { stop = false; break; } else { S.insert(k); } } if (stop) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
### Prompt Generate a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { set<int> S; int a, m; cin >> a >> m; int k = a % m; S.insert(k); bool stop = true; while (k != 0) { int i = k; while (i < m) i *= 2; k = i % m; if (S.count(k)) { stop = false; break; } else { S.insert(k); } } if (stop) cout << "Yes" << endl; else cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> int vis[200000 + 2]; int main() { int a, m; scanf("%d%d", &a, &m); memset(vis, 0, sizeof(vis)); int flag = 0, x = a; for (int i = 0; i < 2 * m; i++) { if (vis[x]) { break; } if (x % m == 0) { flag = 1; break; } x %= m; vis[x] = 1; x += x % m; } if (flag) printf("Yes\n"); else printf("No\n"); return 0; }
### Prompt Your task is to create a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int vis[200000 + 2]; int main() { int a, m; scanf("%d%d", &a, &m); memset(vis, 0, sizeof(vis)); int flag = 0, x = a; for (int i = 0; i < 2 * m; i++) { if (vis[x]) { break; } if (x % m == 0) { flag = 1; break; } x %= m; vis[x] = 1; x += x % m; } if (flag) printf("Yes\n"); else printf("No\n"); return 0; } ```
#include <bits/stdc++.h> using namespace std; long double eps = 1e-9; inline long long int max(long long int a, long long int b) { return (a > b ? a : b); } inline long long int min(long long int a, long long int b) { return a < b ? a : b; } long long int mul(long long int x, long long int y) { return ((x % 100000000) * (y % 100000000)) % 100000000; } long long int binpow(long long int x, long long int y) { long long int z = 1; while (y) { if (y & 1) z = mul(z, x); x = mul(x, x); y >>= 1; } return z; } inline long long int inv(long long int x) { return binpow(x, 100000000 - 2); } inline long long int divide(long long int x, long long int y) { return mul(x, inv(y)); } inline long long int add(long long int x, long long int y) { return ((x % 100000000) + (y % 100000000)) % 100000000; } int main() { long long int a, m; cin >> a >> m; long long int i = 100; while (i--) { a = a + a % m; if (a % m == 0) { cout << "Yes\n"; return 0; } } cout << "No\n"; return 0; }
### Prompt Please create a solution in Cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long double eps = 1e-9; inline long long int max(long long int a, long long int b) { return (a > b ? a : b); } inline long long int min(long long int a, long long int b) { return a < b ? a : b; } long long int mul(long long int x, long long int y) { return ((x % 100000000) * (y % 100000000)) % 100000000; } long long int binpow(long long int x, long long int y) { long long int z = 1; while (y) { if (y & 1) z = mul(z, x); x = mul(x, x); y >>= 1; } return z; } inline long long int inv(long long int x) { return binpow(x, 100000000 - 2); } inline long long int divide(long long int x, long long int y) { return mul(x, inv(y)); } inline long long int add(long long int x, long long int y) { return ((x % 100000000) + (y % 100000000)) % 100000000; } int main() { long long int a, m; cin >> a >> m; long long int i = 100; while (i--) { a = a + a % m; if (a % m == 0) { cout << "Yes\n"; return 0; } } cout << "No\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; for (int i = 0; i < m; i++) { a %= m; if (a == 0) { cout << "Yes" << endl; return 0; } a *= 2; } cout << "No" << endl; return 0; }
### Prompt Please formulate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; for (int i = 0; i < m; i++) { a %= m; if (a == 0) { cout << "Yes" << endl; return 0; } a *= 2; } cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> const long long mod = 998244353; const long long n = 100005; const double EPS = 1e-9; using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, k; cin >> n >> k; if (k == 1 || n % k == 0) cout << "Yes"; else { long long f = 0, temp = n; if (temp > k) temp %= k; long long a = 1; for (long long i = 0; i < 20; i++) { if ((a * temp) % k == 0) { f = 1; break; } a *= 2; } if (f) cout << "Yes"; else cout << "No"; } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> const long long mod = 998244353; const long long n = 100005; const double EPS = 1e-9; using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, k; cin >> n >> k; if (k == 1 || n % k == 0) cout << "Yes"; else { long long f = 0, temp = n; if (temp > k) temp %= k; long long a = 1; for (long long i = 0; i < 20; i++) { if ((a * temp) % k == 0) { f = 1; break; } a *= 2; } if (f) cout << "Yes"; else cout << "No"; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m, i, rem; while (scanf("%d%d", &a, &m) == 2) { for (i = 0; i < 500; i++) { rem = (a % m); if (rem == 0) break; a += rem; } if (rem == 0) printf("Yes\n"); else printf("No\n"); } return 0; }
### Prompt Develop a solution in cpp to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m, i, rem; while (scanf("%d%d", &a, &m) == 2) { for (i = 0; i < 500; i++) { rem = (a % m); if (rem == 0) break; a += rem; } if (rem == 0) printf("Yes\n"); else printf("No\n"); } return 0; } ```
#include <bits/stdc++.h> int main() { int a, b, t; while (scanf("%d%d", &a, &b) != EOF) { t = b; while (t--) { if ((a + a % b) % b == 0) { printf("Yes\n"); return 0; } else a = (a + a % b) % b; } printf("No\n"); } }
### Prompt Please create a solution in Cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int main() { int a, b, t; while (scanf("%d%d", &a, &b) != EOF) { t = b; while (t--) { if ((a + a % b) % b == 0) { printf("Yes\n"); return 0; } else a = (a + a % b) % b; } printf("No\n"); } } ```
#include <bits/stdc++.h> int main(void) { int a, m; scanf("%d%d", &a, &m); int t = m; while (t--) { if ((a + a % m) % m == 0) { printf("Yes\n"); return 0; } else a = (a + a % m) % m; } printf("No\n"); }
### Prompt Your challenge is to write a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int main(void) { int a, m; scanf("%d%d", &a, &m); int t = m; while (t--) { if ((a + a % m) % m == 0) { printf("Yes\n"); return 0; } else a = (a + a % m) % m; } printf("No\n"); } ```
#include <bits/stdc++.h> using namespace std; set<long long> check; int main() { long long a, m; cin >> a >> m; bool flag = false; while (true) { long long ex = a % m; if (ex == 0) { flag = true; break; } else if (check.count(ex) == 1) break; check.insert(ex); a = a + ex; } if (flag) puts("Yes"); else puts("No"); return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; set<long long> check; int main() { long long a, m; cin >> a >> m; bool flag = false; while (true) { long long ex = a % m; if (ex == 0) { flag = true; break; } else if (check.count(ex) == 1) break; check.insert(ex); a = a + ex; } if (flag) puts("Yes"); else puts("No"); return 0; } ```
#include <bits/stdc++.h> int a, b; int vis[100010]; int main() { scanf("%d %d", &a, &b); for (; !vis[a] && a; vis[a] = 1, a = (a * 2) % b) ; printf(a == 0 ? "Yes" : "No"); return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> int a, b; int vis[100010]; int main() { scanf("%d %d", &a, &b); for (; !vis[a] && a; vis[a] = 1, a = (a * 2) % b) ; printf(a == 0 ? "Yes" : "No"); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; while (cin >> a >> b) { for (long long i = 0; i < 1000000; i++) { if (a % b == 0) { cout << "Yes" << "\n"; return 0; } a += a % b; } cout << "No\n"; } return 0; }
### Prompt In Cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long a, b; while (cin >> a >> b) { for (long long i = 0; i < 1000000; i++) { if (a % b == 0) { cout << "Yes" << "\n"; return 0; } a += a % b; } cout << "No\n"; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, m; int main() { scanf("%d%d", &a, &m); int q = a % m; if (m % 2 == 0) { while (m % 2 == 0) m = m / 2; } if (q % 2 == 0 && q > 0) { while (q % 2 == 0) q = q / 2; } if (q % m == 0) printf("Yes\n"); else printf("No\n"); }
### Prompt Your task is to create a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, m; int main() { scanf("%d%d", &a, &m); int q = a % m; if (m % 2 == 0) { while (m % 2 == 0) m = m / 2; } if (q % 2 == 0 && q > 0) { while (q % 2 == 0) q = q / 2; } if (q % m == 0) printf("Yes\n"); else printf("No\n"); } ```
#include <bits/stdc++.h> using namespace std; long long n, m, j, k, i, l, a; int A[2000005]; int main() { scanf("%lld %lld", &a, &n); while (1) { if (a % n == 0) return cout << "Yes", 0; a += a % n; a %= n; if (A[a]) return cout << "No", 0; A[a] = 1; } return 0; }
### Prompt Generate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long n, m, j, k, i, l, a; int A[2000005]; int main() { scanf("%lld %lld", &a, &n); while (1) { if (a % n == 0) return cout << "Yes", 0; a += a % n; a %= n; if (A[a]) return cout << "No", 0; A[a] = 1; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; int i = 10000; while (i--) { if (a % m == 0) { cout << "Yes"; return 0; } a += a % m; } cout << "No"; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; int i = 10000; while (i--) { if (a % m == 0) { cout << "Yes"; return 0; } a += a % m; } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long a, m; cin >> a >> m; vector<bool> u(m, false); while (1) { if (a % m == 0) { cout << "Yes\n"; return 0; } else if (u[a % m] == true) { cout << "No\n"; return 0; } u[a % m] = true; a += a % m; } return 0; }
### Prompt Your task is to create a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long a, m; cin >> a >> m; vector<bool> u(m, false); while (1) { if (a % m == 0) { cout << "Yes\n"; return 0; } else if (u[a % m] == true) { cout << "No\n"; return 0; } u[a % m] = true; a += a % m; } return 0; } ```
#include <bits/stdc++.h> const int maxn = 1e5 + 5; int vis[maxn] = {0}; int main() { int a, m; scanf("%d%d", &a, &m); a %= m; while (a && !vis[a]) { vis[a] = 1; a += a % m; a %= m; } if (a) { printf("No\n"); } else printf("Yes\n"); }
### Prompt In cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> const int maxn = 1e5 + 5; int vis[maxn] = {0}; int main() { int a, m; scanf("%d%d", &a, &m); a %= m; while (a && !vis[a]) { vis[a] = 1; a += a % m; a %= m; } if (a) { printf("No\n"); } else printf("Yes\n"); } ```
#include <bits/stdc++.h> using namespace std; bool cmp(int a, int b) { return a > b; } template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a * b / gcd(a, b); } int mark[1000006]; int main() { ios_base::sync_with_stdio(false); long long a, m, tt; cin >> a >> m; tt = a; while (1) { if (tt % m == 0) { cout << "Yes" << endl; return 0; } else if (mark[tt % m] == 1) { cout << "No" << endl; return 0; } mark[tt % m] = 1; tt = tt + (tt % m); } return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; bool cmp(int a, int b) { return a > b; } template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a * b / gcd(a, b); } int mark[1000006]; int main() { ios_base::sync_with_stdio(false); long long a, m, tt; cin >> a >> m; tt = a; while (1) { if (tt % m == 0) { cout << "Yes" << endl; return 0; } else if (mark[tt % m] == 1) { cout << "No" << endl; return 0; } mark[tt % m] = 1; tt = tt + (tt % m); } return 0; } ```
#include <bits/stdc++.h> using namespace std; long long int n, m, i; int main() { cin >> n >> m; for (i = 1; i <= 10 * 10 * 10 * 10 * 10; i++) { n += n % m; if (n % m == 0) { cout << "Yes"; return 0; } } cout << "No"; return 0; }
### Prompt Develop a solution in cpp to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long int n, m, i; int main() { cin >> n >> m; for (i = 1; i <= 10 * 10 * 10 * 10 * 10; i++) { n += n % m; if (n % m == 0) { cout << "Yes"; return 0; } } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { bool czy; long long x; long long m, pot; int i; cin >> x >> m; czy = false; for (i = 0; i <= 20; i++) { pot = 1 << i; if ((pot * x) % m == 0) czy = true; } if (czy) cout << "Yes\n"; else cout << "No\n"; return 0; }
### Prompt Generate a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { bool czy; long long x; long long m, pot; int i; cin >> x >> m; czy = false; for (i = 0; i <= 20; i++) { pot = 1 << i; if ((pot * x) % m == 0) czy = true; } if (czy) cout << "Yes\n"; else cout << "No\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m, t; cin >> a >> m; while (a < 10000000 && a % m) { a += (a % m); } if (a % m == 0) cout << "Yes"; else cout << "No"; return 0; }
### Prompt Please formulate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m, t; cin >> a >> m; while (a < 10000000 && a % m) { a += (a % m); } if (a % m == 0) cout << "Yes"; else cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, m, x; int ar[100010]; int main() { scanf("%d %d", &a, &m); x = a; while (ar[x] == 0) { ar[x] = 1; if (x % m == 0) { puts("Yes"); return 0; } x += x % m; x = x % m; } puts("No"); }
### Prompt Please create a solution in Cpp to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, m, x; int ar[100010]; int main() { scanf("%d %d", &a, &m); x = a; while (ar[x] == 0) { ar[x] = 1; if (x % m == 0) { puts("Yes"); return 0; } x += x % m; x = x % m; } puts("No"); } ```
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int INFMEM = 63; const int INF = 1061109567; const long long LINF = 4557430888798830399LL; const double DINF = numeric_limits<double>::infinity(); const long long MOD = 1000000007; const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1}; const double PI = 3.141592653589793; inline void open(string a) { freopen((a + ".in").c_str(), "r", stdin); freopen((a + ".out").c_str(), "w", stdout); } inline void fasterios() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } long long n, m; long long mul(long long a, long long b, long long MODULO = MOD) { long long ret = 0; while (b) { if (b & 1) ret = (ret + a) % MODULO; a = (a + a) % MODULO; b >>= 1; } return ret; } long long expo(long long a, long long b, long long MODULO = MOD) { long long ret = 1; while (b) { if (b & 1) ret = (ret * a) % MODULO; a = (a * a) % MODULO; b >>= 1; } return ret; } int main() { cin >> n >> m; long long c = expo(2, m + 4, m); if ((c * n) % m == 0) cout << "Yes" << '\n'; else cout << "No" << '\n'; return 0; }
### Prompt Develop a solution in CPP to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int INFMEM = 63; const int INF = 1061109567; const long long LINF = 4557430888798830399LL; const double DINF = numeric_limits<double>::infinity(); const long long MOD = 1000000007; const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1}; const double PI = 3.141592653589793; inline void open(string a) { freopen((a + ".in").c_str(), "r", stdin); freopen((a + ".out").c_str(), "w", stdout); } inline void fasterios() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } long long n, m; long long mul(long long a, long long b, long long MODULO = MOD) { long long ret = 0; while (b) { if (b & 1) ret = (ret + a) % MODULO; a = (a + a) % MODULO; b >>= 1; } return ret; } long long expo(long long a, long long b, long long MODULO = MOD) { long long ret = 1; while (b) { if (b & 1) ret = (ret * a) % MODULO; a = (a * a) % MODULO; b >>= 1; } return ret; } int main() { cin >> n >> m; long long c = expo(2, m + 4, m); if ((c * n) % m == 0) cout << "Yes" << '\n'; else cout << "No" << '\n'; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; const int M = 5e3 + 50; int n, m, u, k, l, r, t; int cnt, cnt1, cnt2, ans; int mn = INT_MAX; int mx = INT_MIN; const int fx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int fy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; int visited[N]; const int MOD = (1ll << 30); const int mod = 1e9 + 7; bool cmp(pair<int, int> a, pair<int, int> b) { return abs(a.second) > abs(b.second); } bool cmp1(const pair<string, pair<int, int>> &a, const pair<string, pair<int, int>> &b) { return abs(a.second.first) < abs(b.second.first); } bool isPowerOfTwo(int n) { return (ceil(log2(n)) == floor(log2(n))); } int makedigit(string n) { int res = 0; for (int i = 0; i < n.size(); i++) { res = res * 10 + (n[i] - '0'); } return res; } string inttostrng(int a) { ostringstream temp; string str; temp << a; return temp.str(); } void clearr(int vis[N], int n) { for (int i = 0; i < n; i++) { vis[i] = 0; } } long long pow(long long a, long long b, long long m) { long long ans = 1; while (b) { if (b & 1) { ans = (ans * a) % m; } b /= 2; a = (a * a) % m; } return ans; } void solve() { cin >> n >> m; int i = 0; while (i <= 100000) { int rem = n % m; if (rem == 0) { cout << "Yes"; return; } n = (n + n) % m; i++; } cout << "No"; } int main() { ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0); t = 1; while (t--) { solve(); } }
### Prompt In cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; const int M = 5e3 + 50; int n, m, u, k, l, r, t; int cnt, cnt1, cnt2, ans; int mn = INT_MAX; int mx = INT_MIN; const int fx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int fy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; int visited[N]; const int MOD = (1ll << 30); const int mod = 1e9 + 7; bool cmp(pair<int, int> a, pair<int, int> b) { return abs(a.second) > abs(b.second); } bool cmp1(const pair<string, pair<int, int>> &a, const pair<string, pair<int, int>> &b) { return abs(a.second.first) < abs(b.second.first); } bool isPowerOfTwo(int n) { return (ceil(log2(n)) == floor(log2(n))); } int makedigit(string n) { int res = 0; for (int i = 0; i < n.size(); i++) { res = res * 10 + (n[i] - '0'); } return res; } string inttostrng(int a) { ostringstream temp; string str; temp << a; return temp.str(); } void clearr(int vis[N], int n) { for (int i = 0; i < n; i++) { vis[i] = 0; } } long long pow(long long a, long long b, long long m) { long long ans = 1; while (b) { if (b & 1) { ans = (ans * a) % m; } b /= 2; a = (a * a) % m; } return ans; } void solve() { cin >> n >> m; int i = 0; while (i <= 100000) { int rem = n % m; if (rem == 0) { cout << "Yes"; return; } n = (n + n) % m; i++; } cout << "No"; } int main() { ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0); t = 1; while (t--) { solve(); } } ```
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { long long a, m; cin >> a >> m; bool b[m]; for (int i = 0; i < m; i++) b[i] = 0; while (a % m != 0) { if (b[a % m] == 1) { cout << "No"; break; } else b[a % m] = 1; a = a + a % m; } if (a % m == 0) cout << "Yes"; return EXIT_SUCCESS; }
### Prompt Your task is to create a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { long long a, m; cin >> a >> m; bool b[m]; for (int i = 0; i < m; i++) b[i] = 0; while (a % m != 0) { if (b[a % m] == 1) { cout << "No"; break; } else b[a % m] = 1; a = a + a % m; } if (a % m == 0) cout << "Yes"; return EXIT_SUCCESS; } ```
#include <bits/stdc++.h> using namespace std; int a[1000002]; int main() { long long n, m; cin >> n >> m; memset(a, 0, sizeof(a)); bool flag = 0; while (n) { if (n % m == 0) { flag = 1; break; } n = n + n % m; if (a[n % m] == 1) break; a[n % m] = 1; } if (flag) cout << "Yes" << endl; else cout << "No" << endl; }
### Prompt Construct a CPP code solution to the problem outlined: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a[1000002]; int main() { long long n, m; cin >> n >> m; memset(a, 0, sizeof(a)); bool flag = 0; while (n) { if (n % m == 0) { flag = 1; break; } n = n + n % m; if (a[n % m] == 1) break; a[n % m] = 1; } if (flag) cout << "Yes" << endl; else cout << "No" << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d%d", &n, &m); int rem[100005] = {0}; while (rem[n % m] == 0) { rem[n % m] = 1; n = 2 * (n % m); if (n == 0) { printf("Yes\n"); return 0; } } printf("No\n"); }
### Prompt In cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d%d", &n, &m); int rem[100005] = {0}; while (rem[n % m] == 0) { rem[n % m] = 1; n = 2 * (n % m); if (n == 0) { printf("Yes\n"); return 0; } } printf("No\n"); } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; while (scanf("%d%d", &a, &m) != EOF) { bool flag = true; for (int i = 1; i <= 17; i++) { int mod = a % m; if (mod == 0) { flag = false; break; } a = a + mod; } printf("%s\n", flag ? "No" : "Yes"); } }
### Prompt Create a solution in cpp for the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; while (scanf("%d%d", &a, &m) != EOF) { bool flag = true; for (int i = 1; i <= 17; i++) { int mod = a % m; if (mod == 0) { flag = false; break; } a = a + mod; } printf("%s\n", flag ? "No" : "Yes"); } } ```
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } bool check(int x) { while (x % 2 == 0) x /= 2; if (x == 1) return true; return false; } int main() { int a, m; while (cin >> a >> m) { if (a % m == 0) cout << "Yes" << endl; else { m = m / gcd(a, m); if (check(m)) cout << "Yes" << endl; else cout << "No" << endl; } } return 0; }
### Prompt Your task is to create a Cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } bool check(int x) { while (x % 2 == 0) x /= 2; if (x == 1) return true; return false; } int main() { int a, m; while (cin >> a >> m) { if (a % m == 0) cout << "Yes" << endl; else { m = m / gcd(a, m); if (check(m)) cout << "Yes" << endl; else cout << "No" << endl; } } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long a, m, x, i, flag = 0; cin >> a >> m; x = a; for (i = 1; i <= (2 * m); i++) { x += x % m; if (x % m == 0) { flag = 1; break; } } if (flag == 0) cout << "No"; else cout << "Yes"; }
### Prompt Please provide a CPP coded solution to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long a, m, x, i, flag = 0; cin >> a >> m; x = a; for (i = 1; i <= (2 * m); i++) { x += x % m; if (x % m == 0) { flag = 1; break; } } if (flag == 0) cout << "No"; else cout << "Yes"; } ```
#include <bits/stdc++.h> using namespace std; long long fastpow(long long base, long long exp) { long long res = 1; while (exp > 0) { if (exp % 2 == 1) res = (res * base) % 1000000009; base = (base * base) % 1000000009; exp /= 2; } return res % 1000000009; } bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (abs(a.first - a.second) > abs(b.first - b.second)); } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long a, m; cin >> a >> m; long long ans = 0; while (ans <= 20) { if ((a % m) == 0) { cout << "Yes"; return 0; } a = a * 2; ans++; } cout << "No"; return 0; }
### Prompt Develop a solution in CPP to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long fastpow(long long base, long long exp) { long long res = 1; while (exp > 0) { if (exp % 2 == 1) res = (res * base) % 1000000009; base = (base * base) % 1000000009; exp /= 2; } return res % 1000000009; } bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (abs(a.first - a.second) > abs(b.first - b.second)); } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long a, m; cin >> a >> m; long long ans = 0; while (ans <= 20) { if ((a % m) == 0) { cout << "Yes"; return 0; } a = a * 2; ans++; } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); } bool isPrime(long long n) { if (n == 1) return false; if (n == 2) return true; for (long long i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } void solve() { long long n; cin >> n; long long m; cin >> m; for (long long i = 0; i < 18; i++) { if ((n * (1 << i)) % m == 0) { cout << "Yes" << endl; return; } } cout << "No" << endl; } int32_t main() { ios_base ::sync_with_stdio(false), cin.tie(NULL); long long t = 1; while (t--) { solve(); } return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); } bool isPrime(long long n) { if (n == 1) return false; if (n == 2) return true; for (long long i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } void solve() { long long n; cin >> n; long long m; cin >> m; for (long long i = 0; i < 18; i++) { if ((n * (1 << i)) % m == 0) { cout << "Yes" << endl; return; } } cout << "No" << endl; } int32_t main() { ios_base ::sync_with_stdio(false), cin.tie(NULL); long long t = 1; while (t--) { solve(); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; while (a % 2 == 0) a /= 2; while (b % 2 == 0) b /= 2; if (a % b == 0) cout << "Yes" << endl; else cout << "No" << endl; }
### Prompt In Cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; while (a % 2 == 0) a /= 2; while (b % 2 == 0) b /= 2; if (a % b == 0) cout << "Yes" << endl; else cout << "No" << endl; } ```
#include <bits/stdc++.h> using namespace std; int a, m, v[100001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> a >> m; do { if (v[a]) { cout << "No" << "\n"; return 0; } int r = a % m; v[a] = 1; a = (a + r) % m; } while (a % m); cout << "Yes" << "\n"; return 0; }
### Prompt Generate a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, m, v[100001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> a >> m; do { if (v[a]) { cout << "No" << "\n"; return 0; } int r = a % m; v[a] = 1; a = (a + r) % m; } while (a % m); cout << "Yes" << "\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int main() { long long a, m; cin >> a >> m; for (int i = 0; i < int(m + 1); i++) { if (a % m == 0) { cout << "Yes"; return 0; } a += a % m; } cout << "No"; return 0; }
### Prompt Develop a solution in CPP to the problem described below: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int INF = 1e9; int main() { long long a, m; cin >> a >> m; for (int i = 0; i < int(m + 1); i++) { if (a % m == 0) { cout << "Yes"; return 0; } a += a % m; } cout << "No"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m, acum; scanf("%d %d", &a, &m); acum = a; int day = 0; while (day < 20) { day++; acum += acum % m; if (acum % m == 0) { printf("Yes\n"); return 0; } } printf("No\n"); }
### Prompt In Cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m, acum; scanf("%d %d", &a, &m); acum = a; int day = 0; while (day < 20) { day++; acum += acum % m; if (acum % m == 0) { printf("Yes\n"); return 0; } } printf("No\n"); } ```
#include <bits/stdc++.h> using namespace std; int dau[100010]; int m, x; bool kt() { while (dau[m] != 1) { dau[m] = 1; if (m % x == 0) return true; m = (m + m % x) % x; } return false; } int main() { scanf("%d%d", &m, &x); if (kt()) cout << "Yes"; else cout << "No"; fclose(stdin); fclose(stdout); }
### Prompt Your task is to create a cpp solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int dau[100010]; int m, x; bool kt() { while (dau[m] != 1) { dau[m] = 1; if (m % x == 0) return true; m = (m + m % x) % x; } return false; } int main() { scanf("%d%d", &m, &x); if (kt()) cout << "Yes"; else cout << "No"; fclose(stdin); fclose(stdout); } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; if ((a % m) == 0) { cout << "Yes"; } else if ((m & (m - 1)) == 0) { cout << "Yes"; } else if ((m % (a % m)) == 0) { int d = m / (a % m); if ((d & (d - 1)) == 0) { cout << "Yes"; } else cout << "No"; } else cout << "No"; }
### Prompt In Cpp, your task is to solve the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, m; cin >> a >> m; if ((a % m) == 0) { cout << "Yes"; } else if ((m & (m - 1)) == 0) { cout << "Yes"; } else if ((m % (a % m)) == 0) { int d = m / (a % m); if ((d & (d - 1)) == 0) { cout << "Yes"; } else cout << "No"; } else cout << "No"; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long a, b, c = 10000000; bool found = false; cin >> a >> b; while (c--) { if (a % b == 0) { found = true; break; } a += (a % b); } if (found) cout << "Yes" << endl; else cout << "No" << endl; }
### Prompt Create a solution in cpp for the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long a, b, c = 10000000; bool found = false; cin >> a >> b; while (c--) { if (a % b == 0) { found = true; break; } a += (a % b); } if (found) cout << "Yes" << endl; else cout << "No" << endl; } ```
#include <bits/stdc++.h> using namespace std; const int mx = 100010; int b[mx]; int main() { int a, m; while (scanf("%d%d", &a, &m) == 2) { memset(b, 0, sizeof b); while (a) { if (b[a]) break; b[a] = 1; a = (a + a) % m; } if (a) printf("No\n"); else printf("Yes\n"); } }
### Prompt Please formulate a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int mx = 100010; int b[mx]; int main() { int a, m; while (scanf("%d%d", &a, &m) == 2) { memset(b, 0, sizeof b); while (a) { if (b[a]) break; b[a] = 1; a = (a + a) % m; } if (a) printf("No\n"); else printf("Yes\n"); } } ```
#include <bits/stdc++.h> using namespace std; int a, m; vector<int> ans; int main() { cin >> a >> m; ans.push_back(m); while (m % 2 == 0) { m /= 2; ans.push_back(m); } for (int i = 0; i < ans.size(); ++i) if (a % ans[i] == 0) { cout << "Yes" << endl; return 0; } cout << "No" << endl; return 0; }
### Prompt Your challenge is to write a CPP solution to the following problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. Input The first line contains two integers a and m (1 ≤ a, m ≤ 105). Output Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". Examples Input 1 5 Output No Input 3 6 Output Yes ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, m; vector<int> ans; int main() { cin >> a >> m; ans.push_back(m); while (m % 2 == 0) { m /= 2; ans.push_back(m); } for (int i = 0; i < ans.size(); ++i) if (a % ans[i] == 0) { cout << "Yes" << endl; return 0; } cout << "No" << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1][n + 1]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (i == 0 || j == 0) a[i][j] = 1; else { a[i][j] = a[i - 1][j] + a[i][j - 1]; } } cout << a[n - 1][n - 1]; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: An n × n table a is defined as follows: * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. * Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table. You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above. Input The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table. Output Print a single line containing a positive integer m — the maximum value in the table. Examples Input 1 Output 1 Input 5 Output 70 Note In the second test the rows of the table look as follows: {1, 1, 1, 1, 1}, {1, 2, 3, 4, 5}, {1, 3, 6, 10, 15}, {1, 4, 10, 20, 35}, {1, 5, 15, 35, 70}. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1][n + 1]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (i == 0 || j == 0) a[i][j] = 1; else { a[i][j] = a[i - 1][j] + a[i][j - 1]; } } cout << a[n - 1][n - 1]; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n][n]; for (int i = 0; i < n; i++) { a[i][0] = 1; a[0][i] = 1; } for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { a[i][j] = a[i][j - 1] + a[i - 1][j]; } } cout << a[n - 1][n - 1]; }
### Prompt Please create a solution in Cpp to the following problem: An n × n table a is defined as follows: * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. * Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table. You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above. Input The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table. Output Print a single line containing a positive integer m — the maximum value in the table. Examples Input 1 Output 1 Input 5 Output 70 Note In the second test the rows of the table look as follows: {1, 1, 1, 1, 1}, {1, 2, 3, 4, 5}, {1, 3, 6, 10, 15}, {1, 4, 10, 20, 35}, {1, 5, 15, 35, 70}. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n][n]; for (int i = 0; i < n; i++) { a[i][0] = 1; a[0][i] = 1; } for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { a[i][j] = a[i][j - 1] + a[i - 1][j]; } } cout << a[n - 1][n - 1]; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int mat[10][10] = {0}; for (int i = 0; i < 10; i++) { mat[0][i] = {1}; mat[i][0] = {1}; } for (int i = 1; i < 10; i++) { for (int j = 1; j < 10; j++) { mat[i][j] = mat[i - 1][j] + mat[i][j - 1]; } } cout << mat[n - 1][n - 1]; }
### Prompt Develop a solution in Cpp to the problem described below: An n × n table a is defined as follows: * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. * Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table. You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above. Input The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table. Output Print a single line containing a positive integer m — the maximum value in the table. Examples Input 1 Output 1 Input 5 Output 70 Note In the second test the rows of the table look as follows: {1, 1, 1, 1, 1}, {1, 2, 3, 4, 5}, {1, 3, 6, 10, 15}, {1, 4, 10, 20, 35}, {1, 5, 15, 35, 70}. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int mat[10][10] = {0}; for (int i = 0; i < 10; i++) { mat[0][i] = {1}; mat[i][0] = {1}; } for (int i = 1; i < 10; i++) { for (int j = 1; j < 10; j++) { mat[i][j] = mat[i - 1][j] + mat[i][j - 1]; } } cout << mat[n - 1][n - 1]; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<vector<int> > a(n + 1, vector<int>(n + 1)); for (int(i) = 0; (i) < (n + 1); ++(i)) { a[i][1] = 1; a[1][i] = 1; } for (int(i) = (2); (i) < (n + 1); i += 1) { for (int(j) = (2); (j) < (n + 1); j += 1) { a[i][j] = a[i - 1][j] + a[i][j - 1]; } } cout << a[n][n] << endl; return 0; }
### Prompt Your task is to create a CPP solution to the following problem: An n × n table a is defined as follows: * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. * Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table. You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above. Input The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table. Output Print a single line containing a positive integer m — the maximum value in the table. Examples Input 1 Output 1 Input 5 Output 70 Note In the second test the rows of the table look as follows: {1, 1, 1, 1, 1}, {1, 2, 3, 4, 5}, {1, 3, 6, 10, 15}, {1, 4, 10, 20, 35}, {1, 5, 15, 35, 70}. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<vector<int> > a(n + 1, vector<int>(n + 1)); for (int(i) = 0; (i) < (n + 1); ++(i)) { a[i][1] = 1; a[1][i] = 1; } for (int(i) = (2); (i) < (n + 1); i += 1) { for (int(j) = (2); (j) < (n + 1); j += 1) { a[i][j] = a[i - 1][j] + a[i][j - 1]; } } cout << a[n][n] << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; long long g[15][15]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == 0) g[i][j] = 1; else if (j == 0) g[i][j] = 1; else g[i][j] = g[i - 1][j] + g[i][j - 1]; } } cout << g[n - 1][n - 1] << endl; return 0; }
### Prompt Please create a solution in CPP to the following problem: An n × n table a is defined as follows: * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. * Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table. You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above. Input The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table. Output Print a single line containing a positive integer m — the maximum value in the table. Examples Input 1 Output 1 Input 5 Output 70 Note In the second test the rows of the table look as follows: {1, 1, 1, 1, 1}, {1, 2, 3, 4, 5}, {1, 3, 6, 10, 15}, {1, 4, 10, 20, 35}, {1, 5, 15, 35, 70}. ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long g[15][15]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == 0) g[i][j] = 1; else if (j == 0) g[i][j] = 1; else g[i][j] = g[i - 1][j] + g[i][j - 1]; } } cout << g[n - 1][n - 1] << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int q[50][50]; int main() { int n; cin >> n; for (int j = 0; j < n; j++) q[0][j] = 1; for (int j = 1; j < n; j++) { q[j][0] = 1; for (int k = 1; k < n; k++) q[j][k] = q[j - 1][k] + q[j][k - 1]; } cout << q[n - 1][n - 1] << endl; return 0; }
### Prompt Create a solution in CPP for the following problem: An n × n table a is defined as follows: * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. * Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table. You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above. Input The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table. Output Print a single line containing a positive integer m — the maximum value in the table. Examples Input 1 Output 1 Input 5 Output 70 Note In the second test the rows of the table look as follows: {1, 1, 1, 1, 1}, {1, 2, 3, 4, 5}, {1, 3, 6, 10, 15}, {1, 4, 10, 20, 35}, {1, 5, 15, 35, 70}. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int q[50][50]; int main() { int n; cin >> n; for (int j = 0; j < n; j++) q[0][j] = 1; for (int j = 1; j < n; j++) { q[j][0] = 1; for (int k = 1; k < n; k++) q[j][k] = q[j - 1][k] + q[j][k - 1]; } cout << q[n - 1][n - 1] << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int table[10 + 5][10 + 5]; int n; cin >> n; for (int i = 0; i < n; ++i) { table[0][i] = 1; table[i][0] = 1; } for (int i = 1; i < n; ++i) for (int j = 1; j < n; ++j) table[i][j] = table[i - 1][j] + table[i][j - 1]; cout << table[n - 1][n - 1]; }
### Prompt Please create a solution in CPP to the following problem: An n × n table a is defined as follows: * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. * Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table. You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above. Input The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table. Output Print a single line containing a positive integer m — the maximum value in the table. Examples Input 1 Output 1 Input 5 Output 70 Note In the second test the rows of the table look as follows: {1, 1, 1, 1, 1}, {1, 2, 3, 4, 5}, {1, 3, 6, 10, 15}, {1, 4, 10, 20, 35}, {1, 5, 15, 35, 70}. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int table[10 + 5][10 + 5]; int n; cin >> n; for (int i = 0; i < n; ++i) { table[0][i] = 1; table[i][0] = 1; } for (int i = 1; i < n; ++i) for (int j = 1; j < n; ++j) table[i][j] = table[i - 1][j] + table[i][j - 1]; cout << table[n - 1][n - 1]; } ```