output
stringlengths 52
181k
| instruction
stringlengths 296
182k
|
---|---|
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int64_t rnd(int64_t l = 0, int64_t r = INT_MAX) {
return uniform_int_distribution<int64_t>(l, r)(rng);
}
bool in_range(int64_t x, int64_t l, int64_t r) { return l <= x && x <= r; }
template <typename H, typename... T>
void inp(H &head) {
cin >> head;
}
template <typename H, typename... T>
void inp(H &head, T &...tail) {
cin >> head;
inp(tail...);
}
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
for (T &x : a) in >> x;
return in;
}
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T, U> &a) {
in >> a.first >> a.second;
return in;
}
template <int64_t D, typename T>
struct vec : public vector<vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimensions must be greater than zero !!");
template <typename... Args>
vec(int64_t n = 0, Args... args)
: vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) {}
};
template <typename T>
struct vec<1, T> : public vector<T> {
vec(int64_t n = 0, T val = T()) : vector<T>(n, val) {}
};
const int64_t inf = 1e15;
const bool testcases = false;
void init_main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
void solve(int64_t tc) {
int64_t a, m;
cin >> a >> m;
set<int64_t> prev;
int64_t cur = a;
while (cur % m != 0) {
if (prev.count(cur % m)) break;
prev.insert(cur % m);
cur += (cur % m);
}
cout << (cur % m == 0 ? "Yes" : "No") << '\n';
}
int32_t main(int32_t argc, char **argv) {
init_main();
int64_t TC = 1;
if (testcases) cin >> TC;
for (int64_t tc = 1; tc <= TC; ++tc) {
solve(tc);
108;
}
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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int64_t rnd(int64_t l = 0, int64_t r = INT_MAX) {
return uniform_int_distribution<int64_t>(l, r)(rng);
}
bool in_range(int64_t x, int64_t l, int64_t r) { return l <= x && x <= r; }
template <typename H, typename... T>
void inp(H &head) {
cin >> head;
}
template <typename H, typename... T>
void inp(H &head, T &...tail) {
cin >> head;
inp(tail...);
}
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
for (T &x : a) in >> x;
return in;
}
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T, U> &a) {
in >> a.first >> a.second;
return in;
}
template <int64_t D, typename T>
struct vec : public vector<vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimensions must be greater than zero !!");
template <typename... Args>
vec(int64_t n = 0, Args... args)
: vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) {}
};
template <typename T>
struct vec<1, T> : public vector<T> {
vec(int64_t n = 0, T val = T()) : vector<T>(n, val) {}
};
const int64_t inf = 1e15;
const bool testcases = false;
void init_main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
void solve(int64_t tc) {
int64_t a, m;
cin >> a >> m;
set<int64_t> prev;
int64_t cur = a;
while (cur % m != 0) {
if (prev.count(cur % m)) break;
prev.insert(cur % m);
cur += (cur % m);
}
cout << (cur % m == 0 ? "Yes" : "No") << '\n';
}
int32_t main(int32_t argc, char **argv) {
init_main();
int64_t TC = 1;
if (testcases) cin >> TC;
for (int64_t tc = 1; tc <= TC; ++tc) {
solve(tc);
108;
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t, flag, i, j;
while (~scanf("%d %d", &a, &b)) {
i = 0;
flag = 0;
while (i <= 100001) {
if (a % b == 0) {
flag = 1;
break;
} else {
a += a % b;
a %= b;
}
i++;
}
if (flag)
printf("Yes\n");
else
printf("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() {
int a, b, t, flag, i, j;
while (~scanf("%d %d", &a, &b)) {
i = 0;
flag = 0;
while (i <= 100001) {
if (a % b == 0) {
flag = 1;
break;
} else {
a += a % b;
a %= b;
}
i++;
}
if (flag)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
map<int, bool> mp;
int a, m, md;
cin >> a >> m;
while (1) {
md = a % m;
if (!md) {
cout << "Yes" << endl;
break;
} else {
if (mp[md]) {
cout << "No" << endl;
break;
} else {
a = md + md;
mp[md] = true;
}
}
}
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() {
map<int, bool> mp;
int a, m, md;
cin >> a >> m;
while (1) {
md = a % m;
if (!md) {
cout << "Yes" << endl;
break;
} else {
if (mp[md]) {
cout << "No" << endl;
break;
} else {
a = md + md;
mp[md] = true;
}
}
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, k;
int m, V[100000];
long long int a;
scanf("%I64d %d", &a, &m);
memset(V, 0, sizeof(V));
while (a % m != 0) {
if (V[a % m] > 0) {
puts("No");
return 0;
}
V[a % m]++;
a = a + (a % m);
}
puts("Yes");
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;
int main() {
int i, j, k;
int m, V[100000];
long long int a;
scanf("%I64d %d", &a, &m);
memset(V, 0, sizeof(V));
while (a % m != 0) {
if (V[a % m] > 0) {
puts("No");
return 0;
}
V[a % m]++;
a = a + (a % m);
}
puts("Yes");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m, mod;
cin >> a >> m;
for (int i = 0; i < 500; i++) {
mod = a % m;
a += mod;
if (mod == 0) break;
}
if (mod == 0)
cout << "Yes" << endl;
else
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() {
int a, m, mod;
cin >> a >> m;
for (int i = 0; i < 500; i++) {
mod = a % m;
a += mod;
if (mod == 0) break;
}
if (mod == 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
unsigned long long x, m, cnt;
bool check[N];
bool Solve() {
while (1) {
x = x + x % m;
if (x % m == 0) return true;
int Left = x % m;
if (!check[Left])
check[Left] = true;
else
return false;
}
}
int main() {
cin >> x >> m;
if (Solve() == false)
cout << "No" << '\n';
else
cout << "Yes" << '\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 int N = 1e5 + 5;
unsigned long long x, m, cnt;
bool check[N];
bool Solve() {
while (1) {
x = x + x % m;
if (x % m == 0) return true;
int Left = x % m;
if (!check[Left])
check[Left] = true;
else
return false;
}
}
int main() {
cin >> x >> m;
if (Solve() == false)
cout << "No" << '\n';
else
cout << "Yes" << '\n';
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b;
cin >> a >> b;
for (int i = 1; i < 25; i++) {
a = a * 2;
if (a % b == 0) {
cout << "Yes" << endl;
return 0;
}
}
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() {
long long a, b;
cin >> a >> b;
for (int i = 1; i < 25; i++) {
a = a * 2;
if (a % b == 0) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, m;
cin >> a >> m;
while (m % 2 == 0) m /= 2;
cout << (a % m == 0 ? "Yes" : "No");
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;
int main() {
long long int a, m;
cin >> a >> m;
while (m % 2 == 0) m /= 2;
cout << (a % m == 0 ? "Yes" : "No");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, m;
cin >> a >> m;
for (int i = 0; i < 100; i++) {
if (a % m == 0) {
cout << "Yes";
return 0;
}
a += a % m;
}
cout << "No";
}
|
### 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;
for (int i = 0; i < 100; i++) {
if (a % m == 0) {
cout << "Yes";
return 0;
}
a += a % m;
}
cout << "No";
}
```
|
#include <bits/stdc++.h>
int main() {
int a, m, p;
scanf("%d %d", &a, &m);
for (int i = 0; a <= 10000000; i++) {
p = a % m;
if (p == 0) {
printf("Yes");
break;
}
a = a + p;
}
if (a >= 10000000 && p != 0) {
printf("No");
}
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 main() {
int a, m, p;
scanf("%d %d", &a, &m);
for (int i = 0; a <= 10000000; i++) {
p = a % m;
if (p == 0) {
printf("Yes");
break;
}
a = a + p;
}
if (a >= 10000000 && p != 0) {
printf("No");
}
return 0;
}
```
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-8;
const long long mod = (long long)1e9 + 7;
const unsigned long long mx = 133333331;
inline void RI(int &x) {
char c;
while ((c = getchar()) < '0' || c > '9')
;
x = c - '0';
while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0';
}
int flag[100005];
int main() {
int a, m;
while (~scanf("%d%d", &a, &m)) {
memset(flag, 0, sizeof(flag));
int t = 0;
while (1) {
a = a % m;
if (flag[a] && a != 0) {
t = 1;
break;
}
if (a == 0) break;
if (!flag[a]) flag[a] = 1;
a *= 2;
}
if (t)
printf("No\n");
else
printf("Yes\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>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-8;
const long long mod = (long long)1e9 + 7;
const unsigned long long mx = 133333331;
inline void RI(int &x) {
char c;
while ((c = getchar()) < '0' || c > '9')
;
x = c - '0';
while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0';
}
int flag[100005];
int main() {
int a, m;
while (~scanf("%d%d", &a, &m)) {
memset(flag, 0, sizeof(flag));
int t = 0;
while (1) {
a = a % m;
if (flag[a] && a != 0) {
t = 1;
break;
}
if (a == 0) break;
if (!flag[a]) flag[a] = 1;
a *= 2;
}
if (t)
printf("No\n");
else
printf("Yes\n");
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, m;
cin >> a >> m;
for (int i = 0; i < 32; i++) {
if ((a * (1LL << i)) % m == 0) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
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 a, m;
cin >> a >> m;
for (int i = 0; i < 32; i++) {
if ((a * (1LL << i)) % m == 0) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
long long int f[100005];
int main() {
long long a, m, i, sum = 0;
cin >> a >> m;
int flag = 0;
while (1) {
if (a % m == 0) {
flag = 1;
break;
} else {
long long temp = a % m;
if (f[temp] == 1) {
flag = 0;
break;
} else {
f[temp] = 1;
a += temp;
}
}
}
if (flag)
cout << "Yes\n";
else
cout << "No\n";
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;
long long int f[100005];
int main() {
long long a, m, i, sum = 0;
cin >> a >> m;
int flag = 0;
while (1) {
if (a % m == 0) {
flag = 1;
break;
} else {
long long temp = a % m;
if (f[temp] == 1) {
flag = 0;
break;
} else {
f[temp] = 1;
a += temp;
}
}
}
if (flag)
cout << "Yes\n";
else
cout << "No\n";
return 0;
}
```
|
#include <bits/stdc++.h>
const int M = 1e5 + 10;
using namespace std;
int main() {
long long a, m;
while (cin >> a >> m) {
int t = 0, ok = 1;
while (t < m) {
a += a % m;
if (a % m == 0) {
printf("Yes\n");
ok = 0;
break;
}
t++;
}
if (ok) printf("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>
const int M = 1e5 + 10;
using namespace std;
int main() {
long long a, m;
while (cin >> a >> m) {
int t = 0, ok = 1;
while (t < m) {
a += a % m;
if (a % m == 0) {
printf("Yes\n");
ok = 0;
break;
}
t++;
}
if (ok) printf("No\n");
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, m;
cin >> a >> m;
long long MAX = a + 9999997;
long long cnt = 0;
while (cnt <= MAX) {
long long x = a % m;
if ((x + a) % m == 0) {
cout << "Yes" << endl;
return 0;
} else
a += x;
cnt++;
}
cout << "No" << endl;
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;
int main() {
long long a, m;
cin >> a >> m;
long long MAX = a + 9999997;
long long cnt = 0;
while (cnt <= MAX) {
long long x = a % m;
if ((x + a) % m == 0) {
cout << "Yes" << endl;
return 0;
} else
a += x;
cnt++;
}
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> fact(int n) {
unordered_map<int, int> f;
for (int d = 2; d * d <= n; ++d) {
while (n % d == 0) {
f[d]++;
n /= d;
}
}
if (n > 1) {
f[n]++;
}
return f;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a, m;
cin >> a >> m;
unordered_map<int, int> fa = fact(a);
unordered_map<int, int> fn = fact(m);
bool onlytwo = true;
for (auto it : fn) {
if (it.second > fa[it.first] && it.first != 2) {
onlytwo = false;
break;
}
}
cout << (onlytwo ? "Yes\n" : "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;
unordered_map<int, int> fact(int n) {
unordered_map<int, int> f;
for (int d = 2; d * d <= n; ++d) {
while (n % d == 0) {
f[d]++;
n /= d;
}
}
if (n > 1) {
f[n]++;
}
return f;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a, m;
cin >> a >> m;
unordered_map<int, int> fa = fact(a);
unordered_map<int, int> fn = fact(m);
bool onlytwo = true;
for (auto it : fn) {
if (it.second > fa[it.first] && it.first != 2) {
onlytwo = false;
break;
}
}
cout << (onlytwo ? "Yes\n" : "No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int64_t A;
int M;
cin >> A >> M;
int op_count = max(2 * M, 10);
for (int i = 0; i < op_count; ++i) {
int add = A % M;
if (add == 0) {
cout << "Yes" << '\n';
return 0;
}
A += add;
}
cout << "No" << '\n';
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;
int main() {
ios_base::sync_with_stdio(false);
int64_t A;
int M;
cin >> A >> M;
int op_count = max(2 * M, 10);
for (int i = 0; i < op_count; ++i) {
int add = A % M;
if (add == 0) {
cout << "Yes" << '\n';
return 0;
}
A += add;
}
cout << "No" << '\n';
return 0;
}
```
|
#include <bits/stdc++.h>
int a, m;
int mark[100005];
int main() {
scanf("%d %d", &a, &m);
while (true) {
if (!mark[a]) {
mark[a] = 1;
if (a % m == 0) {
printf("Yes");
return 0;
}
a = (a + a % m) % m;
} else
break;
}
printf("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>
int a, m;
int mark[100005];
int main() {
scanf("%d %d", &a, &m);
while (true) {
if (!mark[a]) {
mark[a] = 1;
if (a % m == 0) {
printf("Yes");
return 0;
}
a = (a + a % m) % m;
} else
break;
}
printf("No");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
long long int ABS(long long int a) {
if (a < 0) return (-a);
return a;
}
const int v5 = 100000;
const int v9 = 1000000000;
const int v6 = 1000000;
long long int n, m, k, c = 0;
int a[100001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
while (n % m > 0 && a[n % m] == 0) {
a[n % m] = 1;
n = n + (n % m);
}
if (a[n % m] == 1)
cout << "No"
<< "\n";
else
cout << "Yes"
<< "\n";
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;
long long int ABS(long long int a) {
if (a < 0) return (-a);
return a;
}
const int v5 = 100000;
const int v9 = 1000000000;
const int v6 = 1000000;
long long int n, m, k, c = 0;
int a[100001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
while (n % m > 0 && a[n % m] == 0) {
a[n % m] = 1;
n = n + (n % m);
}
if (a[n % m] == 1)
cout << "No"
<< "\n";
else
cout << "Yes"
<< "\n";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
long long a, m, b[10000005];
int main() {
cin >> a >> m;
for (int i = 1; i <= m; i++) {
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
b[a % m]++;
if (b[a % m] == 2) {
cout << "No" << endl;
return 0;
}
a += a % m;
}
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;
long long a, m, b[10000005];
int main() {
cin >> a >> m;
for (int i = 1; i <= m; i++) {
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
b[a % m]++;
if (b[a % m] == 2) {
cout << "No" << endl;
return 0;
}
a += a % m;
}
cout << "No" << endl;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
if (a % m == 0) {
cout << "Yes";
return 0;
}
a %= m;
bool vis[m + 1];
for (int i = 0; i <= m; i++) vis[i] = false;
vis[a] = true;
int temp = (a + a % m) % m;
while (!vis[temp]) {
if (temp % m == 0) {
cout << "Yes";
return 0;
}
vis[temp] = true;
temp = temp + temp % m;
temp = temp % m;
}
cout << "No";
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() {
int a, m;
cin >> a >> m;
if (a % m == 0) {
cout << "Yes";
return 0;
}
a %= m;
bool vis[m + 1];
for (int i = 0; i <= m; i++) vis[i] = false;
vis[a] = true;
int temp = (a + a % m) % m;
while (!vis[temp]) {
if (temp % m == 0) {
cout << "Yes";
return 0;
}
vis[temp] = true;
temp = temp + temp % m;
temp = temp % m;
}
cout << "No";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
bool flag = false;
int t = m;
while (t--) {
if ((a + a % m) % m == 0) {
flag = true;
} else {
a = (a + a % m) % m;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
|
### 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;
cin >> a >> m;
bool flag = false;
int t = m;
while (t--) {
if ((a + a % m) % m == 0) {
flag = true;
} else {
a = (a + a % m) % m;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
map<int, int> exist;
int flag = 1;
for (int i = 0; i < a; i++) {
int k = a % m;
if (k == 0) {
flag = 0;
break;
}
if (exist.find(k) == exist.end()) {
exist[k]++;
a = a + k;
} else {
break;
}
}
if (flag)
cout << "No";
else
cout << "Yes";
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;
int main() {
int a, m;
cin >> a >> m;
map<int, int> exist;
int flag = 1;
for (int i = 0; i < a; i++) {
int k = a % m;
if (k == 0) {
flag = 0;
break;
}
if (exist.find(k) == exist.end()) {
exist[k]++;
a = a + k;
} else {
break;
}
}
if (flag)
cout << "No";
else
cout << "Yes";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, m;
cin >> a >> m;
long long x = 1LL;
while (x < m) {
x = x * 2;
}
long long y = (x * a) % m;
if (y == 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 main() {
long long a, m;
cin >> a >> m;
long long x = 1LL;
while (x < m) {
x = x * 2;
}
long long y = (x * a) % m;
if (y == 0)
cout << "Yes";
else
cout << "No";
}
```
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int maxn = 100010;
const double eps = 1e-8;
const int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int mod = 1000000007;
const int inf = 0x3fffffff;
const double pi = acos(-1.0);
int n, m, vis[maxn];
int main() {
scanf("%d %d", &n, &m);
while (true) {
if (n == 0) {
printf("Yes\n");
break;
}
if (vis[n] == 1) {
printf("No\n");
break;
}
vis[n] = 1;
n = (n + n) % m;
}
}
|
### 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>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int maxn = 100010;
const double eps = 1e-8;
const int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int mod = 1000000007;
const int inf = 0x3fffffff;
const double pi = acos(-1.0);
int n, m, vis[maxn];
int main() {
scanf("%d %d", &n, &m);
while (true) {
if (n == 0) {
printf("Yes\n");
break;
}
if (vis[n] == 1) {
printf("No\n");
break;
}
vis[n] = 1;
n = (n + n) % m;
}
}
```
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long power(long long x, long long y) {
long long res = 1;
x = x % mod;
while (y > 0) {
if (y & 1) res = (res * x) % mod;
y = y >> 1;
x = (x * x) % mod;
}
return res;
}
long long ncr(long long n, long long r) {
long long res = 1;
if (r > n - r) r = n - r;
for (long long i = 0; i < r; i++) {
res *= (n - i);
res /= (i + 1);
}
return res;
}
long long gcd(long long a, long long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
long long max(long long a, long long b) {
long long ans = a > b ? a : b;
return ans;
}
long long min(long long a, long long b) {
long long ans = a < b ? a : b;
return ans;
}
clock_t time_p = clock();
void rtime() {
time_p = clock() - time_p;
cerr << "******************\nTime taken : "
<< (double)(time_p) / CLOCKS_PER_SEC << "\n";
}
signed main() {
{
long long a, m;
cin >> a >> m;
for (long long i = 0; i < m; i++) {
if (a % m == 0) return cout << "Yes", 0;
a = (a + a % m) % m;
}
cout << "No";
}
rtime();
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;
const long long mod = 1000000007;
long long power(long long x, long long y) {
long long res = 1;
x = x % mod;
while (y > 0) {
if (y & 1) res = (res * x) % mod;
y = y >> 1;
x = (x * x) % mod;
}
return res;
}
long long ncr(long long n, long long r) {
long long res = 1;
if (r > n - r) r = n - r;
for (long long i = 0; i < r; i++) {
res *= (n - i);
res /= (i + 1);
}
return res;
}
long long gcd(long long a, long long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
long long max(long long a, long long b) {
long long ans = a > b ? a : b;
return ans;
}
long long min(long long a, long long b) {
long long ans = a < b ? a : b;
return ans;
}
clock_t time_p = clock();
void rtime() {
time_p = clock() - time_p;
cerr << "******************\nTime taken : "
<< (double)(time_p) / CLOCKS_PER_SEC << "\n";
}
signed main() {
{
long long a, m;
cin >> a >> m;
for (long long i = 0; i < m; i++) {
if (a % m == 0) return cout << "Yes", 0;
a = (a + a % m) % m;
}
cout << "No";
}
rtime();
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long a, m;
cin >> a >> m;
for (int i = 1; i <= m; i++) {
if (a % m == 0) {
printf("Yes\n");
return 0;
} else {
a += (a % m);
}
}
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() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long a, m;
cin >> a >> m;
for (int i = 1; i <= m; i++) {
if (a % m == 0) {
printf("Yes\n");
return 0;
} else {
a += (a % m);
}
}
printf("No\n");
}
```
|
#include <bits/stdc++.h>
using std::cin;
using std::cout;
int main() {
int a, m;
cin >> a >> m;
a %= m;
bool can = false;
for (int i = 0; i < 1e7; i++) {
a *= 2;
if (a >= m) a -= m;
if (a == 0) {
can = true;
break;
}
}
if (can)
cout << "Yes";
else
cout << "No";
cout << '\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 std::cin;
using std::cout;
int main() {
int a, m;
cin >> a >> m;
a %= m;
bool can = false;
for (int i = 0; i < 1e7; i++) {
a *= 2;
if (a >= m) a -= m;
if (a == 0) {
can = true;
break;
}
}
if (can)
cout << "Yes";
else
cout << "No";
cout << '\n';
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, m;
cin >> a >> m;
long long int flag = 0;
for (long long int i = 0; i < m; i++) {
a += (a % m);
if (a % m == 0) {
flag = 1;
break;
}
}
if (flag == 1)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
|
### 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() {
long long int a, m;
cin >> a >> m;
long long int flag = 0;
for (long long int i = 0; i < m; i++) {
a += (a % m);
if (a % m == 0) {
flag = 1;
break;
}
}
if (flag == 1)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int i = 0, j, k, n, m;
cin >> n >> m;
long long int arr[100005] = {0};
while (1) {
k = n % m;
if (k == 0) {
i = 1;
break;
} else {
if (arr[k] > 0) break;
arr[k]++;
n = n + k;
}
}
if (i == 1)
printf("Yes");
else
printf("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 int i = 0, j, k, n, m;
cin >> n >> m;
long long int arr[100005] = {0};
while (1) {
k = n % m;
if (k == 0) {
i = 1;
break;
} else {
if (arr[k] > 0) break;
arr[k]++;
n = n + k;
}
}
if (i == 1)
printf("Yes");
else
printf("No");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int a, m;
cin >> a >> m;
a %= m;
set<int> s;
while (!s.count(a)) {
s.insert(a);
a = (a + a % m) % m;
}
cout << (*s.begin() == 0 ? "Yes\n" : "No\n");
}
|
### 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() {
ios::sync_with_stdio(0);
int a, m;
cin >> a >> m;
a %= m;
set<int> s;
while (!s.count(a)) {
s.insert(a);
a = (a + a % m) % m;
}
cout << (*s.begin() == 0 ? "Yes\n" : "No\n");
}
```
|
#include <bits/stdc++.h>
int vis[100005];
int main() {
int a, m;
scanf("%d%d", &a, &m);
while (1) {
if (vis[a])
break;
else {
vis[a] = 1;
}
if (a == 0) {
printf("Yes\n");
return 0;
} else {
a = (a + a) % 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>
int vis[100005];
int main() {
int a, m;
scanf("%d%d", &a, &m);
while (1) {
if (vis[a])
break;
else {
vis[a] = 1;
}
if (a == 0) {
printf("Yes\n");
return 0;
} else {
a = (a + a) % m;
}
}
printf("No\n");
}
```
|
#include <bits/stdc++.h>
using namespace std;
int tab[100001];
int main() {
long long a, m;
cin >> a >> m;
while (true) {
if (a % m == 0) {
cout << "Yes";
return 0;
}
if (tab[a % m] == 1) {
cout << "No";
return 0;
}
tab[a % m] = 1;
a = a + a % m;
}
}
|
### 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 tab[100001];
int main() {
long long a, m;
cin >> a >> m;
while (true) {
if (a % m == 0) {
cout << "Yes";
return 0;
}
if (tab[a % m] == 1) {
cout << "No";
return 0;
}
tab[a % m] = 1;
a = a + a % m;
}
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
long long x = a;
for (int i = 0; i < 100000; ++i) {
if (x % m == 0) {
cout << "Yes" << endl;
return 0;
}
x = x + x % m;
}
cout << "No" << endl;
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;
long long x = a;
for (int i = 0; i < 100000; ++i) {
if (x % m == 0) {
cout << "Yes" << endl;
return 0;
}
x = x + x % m;
}
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long start, m;
bool answer = false;
cin >> start >> m;
for (int day = 0; day < 100000; ++day) {
if ((start % m) == 0) {
answer = true;
break;
}
start += (start % m);
}
if (answer)
cout << "Yes" << endl;
else
cout << "No" << endl;
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;
int main() {
long long start, m;
bool answer = false;
cin >> start >> m;
for (int day = 0; day < 100000; ++day) {
if ((start % m) == 0) {
answer = true;
break;
}
start += (start % m);
}
if (answer)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int a, m;
int main() {
cin >> a >> m;
while (a <= 10000000) {
a += a % m;
if (a % m == 0) {
printf("Yes");
return 0;
}
}
printf("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 a, m;
int main() {
cin >> a >> m;
while (a <= 10000000) {
a += a % m;
if (a % m == 0) {
printf("Yes");
return 0;
}
}
printf("No");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
return x * x;
}
template <class T>
T gcd(T a, T b) {
return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T bigmod(T p, T e, T M) {
if (e == 0) return 1;
if (e % 2 == 0) {
long long int t = bigmod(p, e / 2, M);
return (T)((t * t) % M);
}
return (T)((long long int)bigmod(p, e - 1, M) * (long long int)p) % M;
}
template <class T>
inline T bigexp(T p, T e) {
if (e == 0) return 1;
if (e % 2 == 0) {
long long int t = bigexp(p, e / 2);
return (T)((t * t));
}
return (T)((long long int)bigexp(p, e - 1) * (long long int)p);
}
template <class T>
inline T modinverse(T a, T M) {
return bigmod(a, M - 2, M);
}
bool isVowel(char ch) {
ch = tolower(ch);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
return true;
return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
int dx4[] = {1, 0, -1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
int a, b, c = 0;
scanf("%d %d", &a, &b);
while (c <= b) {
if (a % b == 0) {
break;
}
a = (a + a % b) % b;
c++;
}
if (c <= b)
printf("Yes");
else
printf("No");
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;
template <class T>
T sqr(T x) {
return x * x;
}
template <class T>
T gcd(T a, T b) {
return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T bigmod(T p, T e, T M) {
if (e == 0) return 1;
if (e % 2 == 0) {
long long int t = bigmod(p, e / 2, M);
return (T)((t * t) % M);
}
return (T)((long long int)bigmod(p, e - 1, M) * (long long int)p) % M;
}
template <class T>
inline T bigexp(T p, T e) {
if (e == 0) return 1;
if (e % 2 == 0) {
long long int t = bigexp(p, e / 2);
return (T)((t * t));
}
return (T)((long long int)bigexp(p, e - 1) * (long long int)p);
}
template <class T>
inline T modinverse(T a, T M) {
return bigmod(a, M - 2, M);
}
bool isVowel(char ch) {
ch = tolower(ch);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
return true;
return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
int dx4[] = {1, 0, -1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
int a, b, c = 0;
scanf("%d %d", &a, &b);
while (c <= b) {
if (a % b == 0) {
break;
}
a = (a + a % b) % b;
c++;
}
if (c <= b)
printf("Yes");
else
printf("No");
return 0;
}
```
|
#include <bits/stdc++.h>
int main() {
int a, b;
int temp;
scanf("%d%d", &a, &b);
while (a <= 6000005) {
temp = a % b;
if (temp == 0) {
printf("Yes\n");
return 0;
}
a += temp;
}
printf("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>
int main() {
int a, b;
int temp;
scanf("%d%d", &a, &b);
while (a <= 6000005) {
temp = a % b;
if (temp == 0) {
printf("Yes\n");
return 0;
}
a += temp;
}
printf("No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int read_int() {
char r;
bool start = false, neg = false;
long long int ret = 0;
while (true) {
r = getchar();
if ((r - '0' < 0 || r - '0' > 9) && r != '-' && !start) {
continue;
}
if ((r - '0' < 0 || r - '0' > 9) && r != '-' && start) {
break;
}
if (start) ret *= 10;
start = true;
if (r == '-')
neg = true;
else
ret += r - '0';
}
if (!neg)
return ret;
else
return -ret;
}
int main() {
int i, flag = 0, a, m;
a = read_int();
m = read_int();
int a1[100007];
int b1[100007];
a1[0] = a;
for (i = 1; i < 20; i++) {
a1[i] = a1[i - 1] * 2;
}
if (a % m == 0)
printf("Yes");
else {
for (i = 0; i < 20; i++) {
if (a1[i] % m == 0) {
flag = 1;
break;
}
}
if (flag == 0) {
printf("No\n");
} else
printf("Yes\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 read_int() {
char r;
bool start = false, neg = false;
long long int ret = 0;
while (true) {
r = getchar();
if ((r - '0' < 0 || r - '0' > 9) && r != '-' && !start) {
continue;
}
if ((r - '0' < 0 || r - '0' > 9) && r != '-' && start) {
break;
}
if (start) ret *= 10;
start = true;
if (r == '-')
neg = true;
else
ret += r - '0';
}
if (!neg)
return ret;
else
return -ret;
}
int main() {
int i, flag = 0, a, m;
a = read_int();
m = read_int();
int a1[100007];
int b1[100007];
a1[0] = a;
for (i = 1; i < 20; i++) {
a1[i] = a1[i - 1] * 2;
}
if (a % m == 0)
printf("Yes");
else {
for (i = 0; i < 20; i++) {
if (a1[i] % m == 0) {
flag = 1;
break;
}
}
if (flag == 0) {
printf("No\n");
} else
printf("Yes\n");
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
long long a, m;
cin >> a >> m;
long long iter = 21;
while (iter--) {
if (a % m == 0) {
puts("Yes");
return 0;
}
a = a + a % m;
}
puts("No");
}
|
### 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;
int32_t main() {
long long a, m;
cin >> a >> m;
long long iter = 21;
while (iter--) {
if (a % m == 0) {
puts("Yes");
return 0;
}
a = a + a % m;
}
puts("No");
}
```
|
#include <bits/stdc++.h>
using namespace std;
bool vis[100001];
int main() {
long long a, m;
cin >> a >> m;
while (true) {
a += (a % m);
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
if (vis[a % m] == true) {
cout << "No\n";
return 0;
}
vis[a % m] = true;
}
}
|
### 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 vis[100001];
int main() {
long long a, m;
cin >> a >> m;
while (true) {
a += (a % m);
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
if (vis[a % m] == true) {
cout << "No\n";
return 0;
}
vis[a % m] = true;
}
}
```
|
#include <bits/stdc++.h>
using ll = long long;
constexpr ll MOD = (ll)(1e8);
using namespace std;
ll a, m;
int main() {
bool ok = false;
cin >> a >> m;
for (int i = 1; i <= 1e5; i++) {
if (a % m == 0) ok = true;
a += (a % m);
}
if (ok)
cout << "Yes" << endl;
else
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 ll = long long;
constexpr ll MOD = (ll)(1e8);
using namespace std;
ll a, m;
int main() {
bool ok = false;
cin >> a >> m;
for (int i = 1; i <= 1e5; i++) {
if (a % m == 0) ok = true;
a += (a % m);
}
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, m, ans = 0;
cin >> a >> m;
for (int i = 0; i < m; i++) {
ans = a % m;
if (ans == 0) {
cout << "Yes" << '\n';
return 0;
}
a = a + ans;
}
cout << "No" << '\n';
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() {
long long a, m, ans = 0;
cin >> a >> m;
for (int i = 0; i < m; i++) {
ans = a % m;
if (ans == 0) {
cout << "Yes" << '\n';
return 0;
}
a = a + ans;
}
cout << "No" << '\n';
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
int main() {
long long int a, m;
cin >> a >> m;
for (int i = 0; i < 1e7; i++) {
if (a % m == 0) {
puts("Yes");
return 0;
}
a = a + (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 INF = 0x3f3f3f3f;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
int main() {
long long int a, m;
cin >> a >> m;
for (int i = 0; i < 1e7; i++) {
if (a % m == 0) {
puts("Yes");
return 0;
}
a = a + (a % m);
}
puts("No");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
bool is[110000];
int a, m;
int main() {
while (cin >> a >> m) {
a %= m;
memset(is, 0, sizeof(is));
for (int i = a % m; is[i] == false; i = (2 * i) % m) is[i] = true;
if (is[0])
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;
bool is[110000];
int a, m;
int main() {
while (cin >> a >> m) {
a %= m;
memset(is, 0, sizeof(is));
for (int i = a % m; is[i] == false; i = (2 * i) % m) is[i] = true;
if (is[0])
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
scanf("%d%d", &a, &b);
int i, temp = 1;
for (i = 1; i <= 18; ++i) {
temp *= 2;
if (a * temp % b == 0) {
printf("Yes\n");
return 0;
}
}
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>
using namespace std;
int main() {
int a, b;
scanf("%d%d", &a, &b);
int i, temp = 1;
for (i = 1; i <= 18; ++i) {
temp *= 2;
if (a * temp % b == 0) {
printf("Yes\n");
return 0;
}
}
printf("No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
int oc[100001] = {0};
int main() {
int a, m;
scanf("%d %d", &a, &m);
while (1) {
oc[a] = 1;
if (!a) {
printf("Yes");
return 0;
}
a += a;
a %= m;
if (oc[a] == 1) break;
}
printf("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>
int oc[100001] = {0};
int main() {
int a, m;
scanf("%d %d", &a, &m);
while (1) {
oc[a] = 1;
if (!a) {
printf("Yes");
return 0;
}
a += a;
a %= m;
if (oc[a] == 1) break;
}
printf("No");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long a, m;
cin >> a >> m;
for (int i = 0; i < m; i++) {
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
a += (a % m);
}
cout << "No" << endl;
}
|
### 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() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long a, m;
cin >> a >> m;
for (int i = 0; i < m; i++) {
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
a += (a % m);
}
cout << "No" << endl;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int a[1000001];
int main() {
int n, m, i = 30;
set<int> s;
cin >> n >> m;
while (i--) {
if (n % m == 0) {
cout << "Yes";
return 0;
} else if (s.find(n) != s.end()) {
cout << "No";
return 0;
} else {
s.insert(n);
n += (n % m);
}
}
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 a[1000001];
int main() {
int n, m, i = 30;
set<int> s;
cin >> n >> m;
while (i--) {
if (n % m == 0) {
cout << "Yes";
return 0;
} else if (s.find(n) != s.end()) {
cout << "No";
return 0;
} else {
s.insert(n);
n += (n % m);
}
}
cout << "No";
}
```
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
bool v[maxn];
int main() {
int a, m;
memset(v, 0, sizeof(v));
scanf("%d%d", &a, &m);
int flag = 0;
while (1) {
if (a % m == 0) {
flag = 1;
break;
} else if (v[a % m])
break;
v[a % m] = 1;
a = a + a % m;
}
if (flag)
printf("Yes\n");
else
printf("No\n");
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 maxn = 1e5 + 10;
bool v[maxn];
int main() {
int a, m;
memset(v, 0, sizeof(v));
scanf("%d%d", &a, &m);
int flag = 0;
while (1) {
if (a % m == 0) {
flag = 1;
break;
} else if (v[a % m])
break;
v[a % m] = 1;
a = a + a % m;
}
if (flag)
printf("Yes\n");
else
printf("No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
int main() {
long long a, m, c, i;
scanf("%I64d %I64d", &a, &m);
for (i = 0; i <= 700; i++) {
c = a % m;
if (c == 0) break;
a = a + c;
}
if (c == 0) {
printf("Yes");
} else
printf("No");
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>
int main() {
long long a, m, c, i;
scanf("%I64d %I64d", &a, &m);
for (i = 0; i <= 700; i++) {
c = a % m;
if (c == 0) break;
a = a + c;
}
if (c == 0) {
printf("Yes");
} else
printf("No");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
set<int> s;
while (cin >> a >> m) {
s.clear();
while (1) {
if (a == 0) {
cout << "Yes" << endl;
break;
} else if (s.count((a + a) % m)) {
cout << "No" << endl;
break;
} else {
a = (a + a) % m;
s.insert(a);
}
}
}
}
|
### 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;
set<int> s;
while (cin >> a >> m) {
s.clear();
while (1) {
if (a == 0) {
cout << "Yes" << endl;
break;
} else if (s.count((a + a) % m)) {
cout << "No" << endl;
break;
} else {
a = (a + a) % m;
s.insert(a);
}
}
}
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, m;
cin >> a >> m;
long long int num = a;
int visited[100005];
memset(visited, 0, sizeof visited);
while (true) {
if (visited[num % m]) break;
if (num % m == 0) {
cout << "Yes" << endl;
return 0;
}
visited[num % m] = 1;
num += (num % m);
}
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() {
long long int a, m;
cin >> a >> m;
long long int num = a;
int visited[100005];
memset(visited, 0, sizeof visited);
while (true) {
if (visited[num % m]) break;
if (num % m == 0) {
cout << "Yes" << endl;
return 0;
}
visited[num % m] = 1;
num += (num % m);
}
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
long long a, m, i;
int main() {
cin >> a >> m;
for (i = 0; i < m; i++) {
a += a % m;
if ((a % m) == 0) {
printf("Yes\n");
return 0;
}
}
printf("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;
long long a, m, i;
int main() {
cin >> a >> m;
for (i = 0; i < m; i++) {
a += a % m;
if ((a % m) == 0) {
printf("Yes\n");
return 0;
}
}
printf("No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, m;
cin >> a >> m;
for (int i = 0; i <= m; i++) {
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
a += a % m;
}
cout << "No" << endl;
}
|
### 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 int a, m;
cin >> a >> m;
for (int i = 0; i <= m; i++) {
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
a += a % m;
}
cout << "No" << endl;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, m;
cin >> a >> m;
for (long long i = 0; i <= (log2(m)); i++) {
long long pr = pow(2.0, i) * a;
if (pr % m == 0) {
cout << "Yes\n";
return 0;
}
}
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() {
long long a, m;
cin >> a >> m;
for (long long i = 0; i <= (log2(m)); i++) {
long long pr = pow(2.0, i) * a;
if (pr % m == 0) {
cout << "Yes\n";
return 0;
}
}
cout << "No\n";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T modinv(T a, T n) {
T i = n, v = 0, d = 1;
while (a > 0) {
T t = i / a, x = a;
a = i % x;
i = x;
x = d;
d = v - t * x;
v = x;
}
return (v + n) % n;
}
long long modpow(long long n, long long k, long long mod) {
long long ans = 1;
while (k > 0) {
if (k & 1) ans = (ans * n) % mod;
k >>= 1;
n = (n * n) % mod;
}
return ans % mod;
}
template <class T>
string str(T Number) {
string Result;
ostringstream convert;
convert << Number;
Result = convert.str();
return Result;
}
int StringToNumber(const string &Text) {
istringstream ss(Text);
int result;
return ss >> result ? result : 0;
}
template <class T>
inline vector<pair<T, int> > FACTORISE(T n) {
vector<pair<T, int> > R;
for (T i = 2; n > 1;) {
if (n % i == 0) {
int C = 0;
for (; n % i == 0; C++, n /= i)
;
R.push_back(make_pair(i, C));
}
i++;
if (i > n / i) i = n;
}
if (n > 1) R.push_back(make_pair(n, 1));
return R;
}
template <class T>
inline T TOTIENT(T n) {
vector<pair<T, int> > R = FACTORISE(n);
T r = n;
for (int i = 0; i < R.size(); i++) r = r / R[i].first * (R[i].first - 1);
return r;
}
template <class T>
inline T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
double rnd(float d) { return floor(d + 0.49); }
int main() {
int a, m;
cin >> a >> m;
int x = gcd(a, m);
while (m % 2 == 0) m = m / 2;
if (x % m == 0)
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;
template <class T>
inline T modinv(T a, T n) {
T i = n, v = 0, d = 1;
while (a > 0) {
T t = i / a, x = a;
a = i % x;
i = x;
x = d;
d = v - t * x;
v = x;
}
return (v + n) % n;
}
long long modpow(long long n, long long k, long long mod) {
long long ans = 1;
while (k > 0) {
if (k & 1) ans = (ans * n) % mod;
k >>= 1;
n = (n * n) % mod;
}
return ans % mod;
}
template <class T>
string str(T Number) {
string Result;
ostringstream convert;
convert << Number;
Result = convert.str();
return Result;
}
int StringToNumber(const string &Text) {
istringstream ss(Text);
int result;
return ss >> result ? result : 0;
}
template <class T>
inline vector<pair<T, int> > FACTORISE(T n) {
vector<pair<T, int> > R;
for (T i = 2; n > 1;) {
if (n % i == 0) {
int C = 0;
for (; n % i == 0; C++, n /= i)
;
R.push_back(make_pair(i, C));
}
i++;
if (i > n / i) i = n;
}
if (n > 1) R.push_back(make_pair(n, 1));
return R;
}
template <class T>
inline T TOTIENT(T n) {
vector<pair<T, int> > R = FACTORISE(n);
T r = n;
for (int i = 0; i < R.size(); i++) r = r / R[i].first * (R[i].first - 1);
return r;
}
template <class T>
inline T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
double rnd(float d) { return floor(d + 0.49); }
int main() {
int a, m;
cin >> a >> m;
int x = gcd(a, m);
while (m % 2 == 0) m = m / 2;
if (x % m == 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int a, m;
cin >> a >> m;
a = a % m;
while (m % 2 == 0) {
m = m / 2;
}
if (a % m == 0) {
cout << "Yes";
} else {
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;
int main() {
ios_base::sync_with_stdio(false);
int a, m;
cin >> a >> m;
a = a % m;
while (m % 2 == 0) {
m = m / 2;
}
if (a % m == 0) {
cout << "Yes";
} else {
cout << "No";
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m;
cin >> n >> m;
long long r = 100, x = n;
while (r--) {
if (x % m == 0) {
cout << "Yes"
<< "\n";
return 0;
}
x += x % m;
}
{
cout << "No"
<< "\n";
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() {
long long n, m;
cin >> n >> m;
long long r = 100, x = n;
while (r--) {
if (x % m == 0) {
cout << "Yes"
<< "\n";
return 0;
}
x += x % m;
}
{
cout << "No"
<< "\n";
return 0;
}
}
```
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
return x * x;
}
template <class T>
inline T cube(T x) {
return x * x * x;
}
template <class T>
inline T powr(T x, T y) {
T ret = 1;
while (y--) ret *= x;
return ret;
}
template <class T>
inline T mod(T a, T b) {
return (a % b + b) % b;
}
template <class T>
inline T GCD(T a, T b) {
if (a < 0) return GCD(-a, b);
if (b < 0) return GCD(a, -b);
return (b == 0) ? a : GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
if (a < 0) return LCM(-a, b);
if (b < 0) return LCM(a, -b);
return a * (b / GCD(a, b));
}
template <class T>
inline bool isPrime(T n) {
if (n <= 1) return false;
for (T i = 2; i * i <= n; i++)
if (n % i == 0) return false;
return true;
}
template <class T>
inline void debug(T x) {
cout << "x = " << x << endl;
}
template <class T1, class T2>
inline void debug(T1 x, T2 y) {
cout << "x = " << x << ", y = " << y << endl;
}
template <class T1, class T2, class T3>
inline void debug(T1 x, T2 y, T3 z) {
cout << "x = " << x << ", y = " << y << ", z = " << z << endl;
}
int dx[] = {+1, -1, +0, +0};
int dy[] = {+0, +0, +1, -1};
int ck[1000001] = {0};
int main() {
int a, n;
cin >> a >> n;
int f = 0, x;
for (;;) {
x = a % n;
if (!x) break;
if (ck[x]) {
f = 1;
break;
} else {
ck[x] = 1;
a += x;
}
}
if (f)
printf("No");
else
printf("Yes");
printf("\n");
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;
template <class T>
inline T sqr(T x) {
return x * x;
}
template <class T>
inline T cube(T x) {
return x * x * x;
}
template <class T>
inline T powr(T x, T y) {
T ret = 1;
while (y--) ret *= x;
return ret;
}
template <class T>
inline T mod(T a, T b) {
return (a % b + b) % b;
}
template <class T>
inline T GCD(T a, T b) {
if (a < 0) return GCD(-a, b);
if (b < 0) return GCD(a, -b);
return (b == 0) ? a : GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
if (a < 0) return LCM(-a, b);
if (b < 0) return LCM(a, -b);
return a * (b / GCD(a, b));
}
template <class T>
inline bool isPrime(T n) {
if (n <= 1) return false;
for (T i = 2; i * i <= n; i++)
if (n % i == 0) return false;
return true;
}
template <class T>
inline void debug(T x) {
cout << "x = " << x << endl;
}
template <class T1, class T2>
inline void debug(T1 x, T2 y) {
cout << "x = " << x << ", y = " << y << endl;
}
template <class T1, class T2, class T3>
inline void debug(T1 x, T2 y, T3 z) {
cout << "x = " << x << ", y = " << y << ", z = " << z << endl;
}
int dx[] = {+1, -1, +0, +0};
int dy[] = {+0, +0, +1, -1};
int ck[1000001] = {0};
int main() {
int a, n;
cin >> a >> n;
int f = 0, x;
for (;;) {
x = a % n;
if (!x) break;
if (ck[x]) {
f = 1;
break;
} else {
ck[x] = 1;
a += x;
}
}
if (f)
printf("No");
else
printf("Yes");
printf("\n");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int n, m, viz[1000010];
int main() {
cin >> n >> m;
n %= m;
while (1) {
if (!n) {
cout << "Yes";
return 0;
}
if (viz[n]) {
cout << "No";
return 0;
}
viz[n] = 1;
n += n % m;
n %= 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 n, m, viz[1000010];
int main() {
cin >> n >> m;
n %= m;
while (1) {
if (!n) {
cout << "Yes";
return 0;
}
if (viz[n]) {
cout << "No";
return 0;
}
viz[n] = 1;
n += n % m;
n %= m;
}
return 0;
}
```
|
#include <bits/stdc++.h>
int main() {
long long int a, m, mod, t, i;
int vis[100000];
scanf("%I64d", &a);
scanf("%I64d", &m);
for (i = 0; i < m; i++) vis[i] = 0;
mod = a % m;
while (mod != 0 && vis[mod] == 0) {
vis[mod] = 1;
a = a + mod;
mod = a % m;
}
if (mod == 0)
printf("Yes\n");
else
printf("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>
int main() {
long long int a, m, mod, t, i;
int vis[100000];
scanf("%I64d", &a);
scanf("%I64d", &m);
for (i = 0; i < m; i++) vis[i] = 0;
mod = a % m;
while (mod != 0 && vis[mod] == 0) {
vis[mod] = 1;
a = a + mod;
mod = a % m;
}
if (mod == 0)
printf("Yes\n");
else
printf("No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
if (a % b == 0)
return b;
else
return gcd(b, a % b);
}
int main() {
long long int a, m, flag = 0, hash[100005], i, j;
cin >> a >> m;
for (i = 0; i < m; i++) hash[i] = 0;
while (1) {
if (a % m == 0) {
flag = 1;
break;
} else {
if (hash[(a % m)] == 0)
hash[a % m] = 1;
else
break;
}
a += a % m;
}
if (flag == 1)
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>
using namespace std;
int gcd(int a, int b) {
if (a % b == 0)
return b;
else
return gcd(b, a % b);
}
int main() {
long long int a, m, flag = 0, hash[100005], i, j;
cin >> a >> m;
for (i = 0; i < m; i++) hash[i] = 0;
while (1) {
if (a % m == 0) {
flag = 1;
break;
} else {
if (hash[(a % m)] == 0)
hash[a % m] = 1;
else
break;
}
a += a % m;
}
if (flag == 1)
cout << "Yes";
else
cout << "No";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int aa[100005];
int main() {
long long a, m;
cin >> a >> m;
if (a % m == 0)
cout << "Yes";
else {
long long bbb;
long long begin = a;
long long produce = a % m;
long long end = begin + produce;
long long sign = 0;
while (1) {
if (produce == 0) {
sign = 1;
break;
}
if (aa[produce] == 0)
aa[produce] = 1;
else if (aa[produce] == 1) {
sign = 0;
break;
}
begin = end;
produce = begin % m;
end = begin + produce;
}
if (sign == 1)
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 aa[100005];
int main() {
long long a, m;
cin >> a >> m;
if (a % m == 0)
cout << "Yes";
else {
long long bbb;
long long begin = a;
long long produce = a % m;
long long end = begin + produce;
long long sign = 0;
while (1) {
if (produce == 0) {
sign = 1;
break;
}
if (aa[produce] == 0)
aa[produce] = 1;
else if (aa[produce] == 1) {
sign = 0;
break;
}
begin = end;
produce = begin % m;
end = begin + produce;
}
if (sign == 1)
cout << "Yes";
else
cout << "No";
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
while (a <= 1e8) {
a += a % m;
if (a % m == 0) cout << "Yes", exit(0);
}
cout << "No" << endl;
}
|
### 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 a, m;
cin >> a >> m;
while (a <= 1e8) {
a += a % m;
if (a % m == 0) cout << "Yes", exit(0);
}
cout << "No" << endl;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long a, m;
bool stop = 0;
cin >> a >> m;
map<long long, long long> m1;
while (true) {
long long x = a % m;
if (x == 0) {
stop = 1;
break;
}
if (m1[x] == 1) {
break;
}
m1[x] = 1;
a += x;
}
if (stop) {
cout << "Yes" << endl;
} else {
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() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long a, m;
bool stop = 0;
cin >> a >> m;
map<long long, long long> m1;
while (true) {
long long x = a % m;
if (x == 0) {
stop = 1;
break;
}
if (m1[x] == 1) {
break;
}
m1[x] = 1;
a += x;
}
if (stop) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
```
|
#include <bits/stdc++.h>
int main() {
int a, b;
scanf("%d%d", &a, &b);
while ((b % 2) == 0) {
b /= 2;
}
if (a % b == 0) {
printf("Yes\n");
} else {
printf("No\n");
}
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 main() {
int a, b;
scanf("%d%d", &a, &b);
while ((b % 2) == 0) {
b /= 2;
}
if (a % b == 0) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}
```
|
#include <bits/stdc++.h>
void dout() { printf("\n"); }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {}
template <typename T>
std::string toString(T val) {
std::ostringstream oss;
oss << val;
return oss.str();
}
template <typename T>
T fromString(const std::string& s) {
std::istringstream iss(s);
T res;
iss >> res;
return res;
}
using namespace std;
int main() {
int a, m;
scanf("%d", &a);
scanf("%d", &m);
set<int> pred;
int x = a;
while (x % m != 0) {
int b = x % m;
x += b;
if (pred.find(b) != pred.end()) break;
pred.insert(b);
}
if (x % m == 0)
printf("Yes");
else
printf("No");
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>
void dout() { printf("\n"); }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {}
template <typename T>
std::string toString(T val) {
std::ostringstream oss;
oss << val;
return oss.str();
}
template <typename T>
T fromString(const std::string& s) {
std::istringstream iss(s);
T res;
iss >> res;
return res;
}
using namespace std;
int main() {
int a, m;
scanf("%d", &a);
scanf("%d", &m);
set<int> pred;
int x = a;
while (x % m != 0) {
int b = x % m;
x += b;
if (pred.find(b) != pred.end()) break;
pred.insert(b);
}
if (x % m == 0)
printf("Yes");
else
printf("No");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long a, m;
cin >> a >> m;
set<long long> s;
while (s.find(a) == s.end()) {
s.insert(a);
a = (a + a % m) % m;
}
if (s.find(0) != s.end())
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;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long a, m;
cin >> a >> m;
set<long long> s;
while (s.find(a) == s.end()) {
s.insert(a);
a = (a + a % m) % m;
}
if (s.find(0) != s.end())
cout << "Yes";
else
cout << "No";
}
```
|
#include <bits/stdc++.h>
using namespace std;
long long a, m;
bool mark[100001];
int main() {
cin >> a >> m;
memset(mark, 0, sizeof(mark));
a %= m;
mark[a] = true;
while (true) {
a = (a * 2) % m;
if (a == 0) {
cout << "Yes";
break;
}
if (mark[a]) {
cout << "No";
break;
}
mark[a] = true;
}
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;
long long a, m;
bool mark[100001];
int main() {
cin >> a >> m;
memset(mark, 0, sizeof(mark));
a %= m;
mark[a] = true;
while (true) {
a = (a * 2) % m;
if (a == 0) {
cout << "Yes";
break;
}
if (mark[a]) {
cout << "No";
break;
}
mark[a] = true;
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, x;
cin >> n >> x;
if (n % x == 0) return printf("Yes\n"), 0;
long long int result = 100000;
long long int _count = 0;
while (result--) {
n = n + (n % x);
if (n % x == 0) return printf("Yes\n"), 0;
}
printf("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 n, x;
cin >> n >> x;
if (n % x == 0) return printf("Yes\n"), 0;
long long int result = 100000;
long long int _count = 0;
while (result--) {
n = n + (n % x);
if (n % x == 0) return printf("Yes\n"), 0;
}
printf("No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, n;
int arr[100005];
memset(arr, 0, sizeof(arr));
cin >> a >> n;
while (1) {
if (arr[a] == 1) {
cout << "No\n";
break;
}
if (a % n == 0) {
cout << "Yes\n";
break;
}
arr[a] = 1;
a = (a + a) % 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() {
int a, n;
int arr[100005];
memset(arr, 0, sizeof(arr));
cin >> a >> n;
while (1) {
if (arr[a] == 1) {
cout << "No\n";
break;
}
if (a % n == 0) {
cout << "Yes\n";
break;
}
arr[a] = 1;
a = (a + a) % n;
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
long long int i, j, k, l, a, b, c, d, t, flag = 0, n;
cin >> a >> b;
c = max(a, b);
while (a <= c * c) {
if (a % b == 0) {
flag = 1;
}
a = a * 2;
}
if (flag == 1) {
cout << "Yes" << endl;
} else {
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() {
ios::sync_with_stdio(false);
long long int i, j, k, l, a, b, c, d, t, flag = 0, n;
cin >> a >> b;
c = max(a, b);
while (a <= c * c) {
if (a % b == 0) {
flag = 1;
}
a = a * 2;
}
if (flag == 1) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int n, m, i = 0;
int main() {
cin >> n >> m;
while (n % m != 0 && i < m) {
n = (n + (n % m)) % m;
i++;
}
if (n % m == 0)
cout << "Yes";
else
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;
int n, m, i = 0;
int main() {
cin >> n >> m;
while (n % m != 0 && i < m) {
n = (n + (n % m)) % m;
i++;
}
if (n % m == 0)
cout << "Yes";
else
cout << "No";
return 0;
}
```
|
#include <bits/stdc++.h>
int main() {
long int x, m, c = 0, day;
scanf("%d%d", &x, &m);
for (day = 1; day <= 1000; day++) {
x += (x % m);
if (x % m == 0) {
printf("Yes\n");
break;
}
c++;
}
if (c == 1000) 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() {
long int x, m, c = 0, day;
scanf("%d%d", &x, &m);
for (day = 1; day <= 1000; day++) {
x += (x % m);
if (x % m == 0) {
printf("Yes\n");
break;
}
c++;
}
if (c == 1000) printf("No\n");
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m, x, t[100010] = {0};
cin >> a >> m;
a = a % m;
t[a]++;
while ((t[(a + a % m) % m] == 0) && (t[0] == 0)) {
a = (a + a % m) % m;
t[a]++;
}
if (t[0] != 0)
cout << "Yes";
else
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() {
int a, m, x, t[100010] = {0};
cin >> a >> m;
a = a % m;
t[a]++;
while ((t[(a + a % m) % m] == 0) && (t[0] == 0)) {
a = (a + a % m) % m;
t[a]++;
}
if (t[0] != 0)
cout << "Yes";
else
cout << "No";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int num, num1, res;
int limit = 1000;
scanf("%d %d", &num, &num1);
while (limit--) {
res = num % num1;
if (res == 0) {
printf("Yes\n");
return 0;
}
num += res;
}
printf("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() {
int num, num1, res;
int limit = 1000;
scanf("%d %d", &num, &num1);
while (limit--) {
res = num % num1;
if (res == 0) {
printf("Yes\n");
return 0;
}
num += res;
}
printf("No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int compare(const void* a, const void* b) {
const long long* x = (long long*)a;
const long long* y = (long long*)b;
if (*x > *y)
return 1;
else if (*x < *y)
return -1;
return 0;
}
void solve() {
long long a, n;
scanf("%lld%lld", &a, &n);
long long kmax = ceil(log2(n)) + 1;
if (kmax < 0) {
printf("No\n");
return;
}
long long i = 1;
while (i <= kmax) {
if (a % n == 0) {
printf("Yes\n");
return;
}
a += a % n;
i++;
}
printf("No\n");
return;
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
long long t, z = 1;
t = 1;
while (z <= t) {
solve();
z++;
}
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;
const int mod = 1e9 + 7;
int compare(const void* a, const void* b) {
const long long* x = (long long*)a;
const long long* y = (long long*)b;
if (*x > *y)
return 1;
else if (*x < *y)
return -1;
return 0;
}
void solve() {
long long a, n;
scanf("%lld%lld", &a, &n);
long long kmax = ceil(log2(n)) + 1;
if (kmax < 0) {
printf("No\n");
return;
}
long long i = 1;
while (i <= kmax) {
if (a % n == 0) {
printf("Yes\n");
return;
}
a += a % n;
i++;
}
printf("No\n");
return;
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
long long t, z = 1;
t = 1;
while (z <= t) {
solve();
z++;
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
int stop = 0;
for (int i = 0; i < m; i++) {
a = a + a % m;
a %= m;
if (a % m == 0) {
stop = 1;
}
}
if (stop)
printf("Yes\n");
else
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>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
int stop = 0;
for (int i = 0; i < m; i++) {
a = a + a % m;
a %= m;
if (a % m == 0) {
stop = 1;
}
}
if (stop)
printf("Yes\n");
else
printf("No\n");
}
```
|
#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
const int INF = 1000000000, mod = 1000000007;
const long long LLINF = 1000000000000000000ll;
bool used[N];
int main() {
long long fst, x, y;
cin >> x >> y;
if (x % y == 0) {
cout << "Yes";
return 0;
}
while (!used[x % y]) {
used[x % y] = 1;
x += x % y;
if (x % y == 0) {
cout << "Yes";
return 0;
}
}
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;
const int N = 111111;
const int INF = 1000000000, mod = 1000000007;
const long long LLINF = 1000000000000000000ll;
bool used[N];
int main() {
long long fst, x, y;
cin >> x >> y;
if (x % y == 0) {
cout << "Yes";
return 0;
}
while (!used[x % y]) {
used[x % y] = 1;
x += x % y;
if (x % y == 0) {
cout << "Yes";
return 0;
}
}
cout << "No";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m, rem;
cin >> a >> m;
int lim = 100;
bool flag = false;
while (lim--) {
rem = a % m;
if (rem == 0) {
cout << "Yes";
flag = true;
break;
}
a += rem;
}
if (flag == false) {
cout << "No";
}
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;
int main() {
int a, m, rem;
cin >> a >> m;
int lim = 100;
bool flag = false;
while (lim--) {
rem = a % m;
if (rem == 0) {
cout << "Yes";
flag = true;
break;
}
a += rem;
}
if (flag == false) {
cout << "No";
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long a, m;
cin >> a >> m;
for (int i = 0; i < m; i++) {
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
a = a + a % m;
}
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() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long a, m;
cin >> a >> m;
for (int i = 0; i < m; i++) {
if (a % m == 0) {
cout << "Yes" << endl;
return 0;
}
a = a + a % m;
}
cout << "No" << endl;
}
```
|
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long n, m;
cin >> n >> m;
for (int i = 1;; i++) {
if (n % m == 0) {
cout << "Yes" << '\n';
return 0;
}
if (i == 1e6) break;
n += n % m;
}
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 long long inf = 1e18;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long n, m;
cin >> n >> m;
for (int i = 1;; i++) {
if (n % m == 0) {
cout << "Yes" << '\n';
return 0;
}
if (i == 1e6) break;
n += n % m;
}
cout << "No" << '\n';
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& output, vector<T>& v) {
output << "[ ";
if (int(v.size())) {
output << v[0];
}
for (int i = 1; i < int(v.size()); i++) {
output << ", " << v[i];
}
output << " ]";
return output;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& output, pair<T1, T2>& p) {
output << "( " << p.first << ", " << p.second << " )";
return output;
}
template <typename T>
ostream& operator,(ostream& output, T x) {
output << x << " ";
return output;
}
bool visited[100007];
int main() {
memset(visited, 0, sizeof(visited));
int a, m;
cin >> a >> m;
while (a != 0) {
if (visited[a]) break;
visited[a] = 1;
a = (a * 2) % m;
}
if (a == 0) {
cout << "Yes";
} 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;
template <typename T>
ostream& operator<<(ostream& output, vector<T>& v) {
output << "[ ";
if (int(v.size())) {
output << v[0];
}
for (int i = 1; i < int(v.size()); i++) {
output << ", " << v[i];
}
output << " ]";
return output;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& output, pair<T1, T2>& p) {
output << "( " << p.first << ", " << p.second << " )";
return output;
}
template <typename T>
ostream& operator,(ostream& output, T x) {
output << x << " ";
return output;
}
bool visited[100007];
int main() {
memset(visited, 0, sizeof(visited));
int a, m;
cin >> a >> m;
while (a != 0) {
if (visited[a]) break;
visited[a] = 1;
a = (a * 2) % m;
}
if (a == 0) {
cout << "Yes";
} else {
cout << "No";
}
}
```
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647, MOD = 1000 * 1000 * 1000 + 7;
const double eps = 1e-8;
void Error(string err) {
cout << err;
cerr << "_" << err << "_";
exit(0);
}
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
const int sz = 100 * 1000;
int main() {
int x, m;
cin >> x >> m;
set<int> seen;
bool yes = true;
for (int i = 0; i < (1000111); i++) {
int a = x % m;
if (a == 0) break;
if (seen.find(a) != seen.end()) {
yes = false;
break;
}
seen.insert(a);
x += a;
}
if (yes)
cout << "Yes\n";
else
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;
const int INF = 2147483647, MOD = 1000 * 1000 * 1000 + 7;
const double eps = 1e-8;
void Error(string err) {
cout << err;
cerr << "_" << err << "_";
exit(0);
}
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
const int sz = 100 * 1000;
int main() {
int x, m;
cin >> x >> m;
set<int> seen;
bool yes = true;
for (int i = 0; i < (1000111); i++) {
int a = x % m;
if (a == 0) break;
if (seen.find(a) != seen.end()) {
yes = false;
break;
}
seen.insert(a);
x += a;
}
if (yes)
cout << "Yes\n";
else
cout << "No\n";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
bool used[N + 1];
int main() {
int a, m, now;
cin >> a >> m;
now = a;
used[now] = 1;
while (1) {
if (now % m == 0) {
cout << "Yes" << endl;
return 0;
}
now = (now + (now % m)) % m;
if (used[now]) {
cout << "No" << endl;
return 0;
}
used[now] = 1;
}
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;
bool used[N + 1];
int main() {
int a, m, now;
cin >> a >> m;
now = a;
used[now] = 1;
while (1) {
if (now % m == 0) {
cout << "Yes" << endl;
return 0;
}
now = (now + (now % m)) % m;
if (used[now]) {
cout << "No" << endl;
return 0;
}
used[now] = 1;
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
while (m % 2 == 0) m /= 2;
if (a % m == 0)
cout << "Yes";
else
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() {
int a, m;
cin >> a >> m;
while (m % 2 == 0) m /= 2;
if (a % m == 0)
cout << "Yes";
else
cout << "No";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, m;
cin >> a >> m;
set<int> s;
int t = a;
int cur;
while (true) {
int remain = t % m;
if (remain == 0) {
cout << "Yes" << endl;
return 0;
}
cur = s.size();
s.insert(remain);
if (s.size() == cur) {
cout << "No" << endl;
return 0;
}
t += remain;
}
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;
int main() {
int a, m;
cin >> a >> m;
set<int> s;
int t = a;
int cur;
while (true) {
int remain = t % m;
if (remain == 0) {
cout << "Yes" << endl;
return 0;
}
cur = s.size();
s.insert(remain);
if (s.size() == cur) {
cout << "No" << endl;
return 0;
}
t += remain;
}
return 0;
}
```
|
#include <bits/stdc++.h>
int main() {
int a, b;
int vis[111111] = {0};
scanf("%d%d", &a, &b);
while (1) {
if (a == 0) {
printf("Yes\n");
return 0;
}
if (vis[a] == 1) {
printf("No\n");
return 0;
}
vis[a] = 1;
a = (a + a) % b;
}
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 main() {
int a, b;
int vis[111111] = {0};
scanf("%d%d", &a, &b);
while (1) {
if (a == 0) {
printf("Yes\n");
return 0;
}
if (vis[a] == 1) {
printf("No\n");
return 0;
}
vis[a] = 1;
a = (a + a) % b;
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
bool fun(int m) {
while (m) {
if (m == 1) break;
if (m % 2 != 0) return 0;
m /= 2;
}
return 1;
}
int gcd(int a, int b) {
if (a < b) swap(a, b);
return b == 0 ? a : gcd(b, a % b);
}
int main() {
int a, m;
scanf("%d%d", &a, &m);
int flag = 0;
if (a % m == 0)
flag = 1;
else
m /= gcd(a, m);
if (fun(m)) flag = 1;
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>
using namespace std;
bool fun(int m) {
while (m) {
if (m == 1) break;
if (m % 2 != 0) return 0;
m /= 2;
}
return 1;
}
int gcd(int a, int b) {
if (a < b) swap(a, b);
return b == 0 ? a : gcd(b, a % b);
}
int main() {
int a, m;
scanf("%d%d", &a, &m);
int flag = 0;
if (a % m == 0)
flag = 1;
else
m /= gcd(a, m);
if (fun(m)) flag = 1;
if (flag)
printf("Yes\n");
else
printf("No\n");
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m;
cin >> n >> m;
long long f = 1;
for (long long i = 0; i < 100000; i++) {
n += (n % m);
if (n % m == 0) {
f = 0;
break;
}
}
if (!f)
cout << "Yes" << endl;
else
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() {
long long n, m;
cin >> n >> m;
long long f = 1;
for (long long i = 0; i < 100000; i++) {
n += (n % m);
if (n % m == 0) {
f = 0;
break;
}
}
if (!f)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int a, m;
cin >> a >> m;
vector<bool> aa(1e6);
aa[a % m] = true;
int next = (a + a % m) % m;
bool found = (a % m == 0);
while (!found && !aa[next]) {
aa[next] = true;
next = (next + next % m) % m;
found = (next == 0);
}
cout << (found ? "Yes" : "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() {
ios_base::sync_with_stdio(false);
int a, m;
cin >> a >> m;
vector<bool> aa(1e6);
aa[a % m] = true;
int next = (a + a % m) % m;
bool found = (a % m == 0);
while (!found && !aa[next]) {
aa[next] = true;
next = (next + next % m) % m;
found = (next == 0);
}
cout << (found ? "Yes" : "No") << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a, m;
cin >> a >> m;
while (m % 2 == 0) {
m /= 2;
}
if (a % m == 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() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a, m;
cin >> a >> m;
while (m % 2 == 0) {
m /= 2;
}
if (a % m == 0) {
cout << "Yes";
} else {
cout << "No";
}
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T modinv(T a, T n) {
T i = n, v = 0, d = 1;
while (a > 0) {
T t = i / a, x = a;
a = i % x;
i = x;
x = d;
d = v - t * x;
v = x;
}
return (v + n) % n;
}
long long modpow(long long n, long long k, long long mod) {
long long ans = 1;
while (k > 0) {
if (k & 1) ans = (ans * n) % mod;
k >>= 1;
n = (n * n) % mod;
}
return ans % mod;
}
template <class T>
string str(T Number) {
string Result;
ostringstream convert;
convert << Number;
Result = convert.str();
return Result;
}
int StringToNumber(const string &Text) {
istringstream ss(Text);
int result;
return ss >> result ? result : 0;
}
template <class T>
inline vector<pair<T, int> > FACTORISE(T n) {
vector<pair<T, int> > R;
for (T i = 2; n > 1;) {
if (n % i == 0) {
int C = 0;
for (; n % i == 0; C++, n /= i)
;
R.push_back(make_pair(i, C));
}
i++;
if (i > n / i) i = n;
}
if (n > 1) R.push_back(make_pair(n, 1));
return R;
}
template <class T>
inline T TOTIENT(T n) {
vector<pair<T, int> > R = FACTORISE(n);
T r = n;
for (int i = 0; i < R.size(); i++) r = r / R[i].first * (R[i].first - 1);
return r;
}
template <class T>
inline T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
double rnd(float d) { return floor(d + 0.49); }
int main() {
int a, m;
cin >> a >> m;
int x = gcd(a, m);
set<int> ans;
int flag = 0;
long long sum = a;
while (1) {
sum = sum + sum % m;
if (sum % m == 0) {
flag = 1;
break;
}
if (ans.find(sum % m) != ans.end()) break;
ans.insert(sum % m);
}
if (flag == 0)
cout << "No" << endl;
else
cout << "Yes" << 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;
template <class T>
inline T modinv(T a, T n) {
T i = n, v = 0, d = 1;
while (a > 0) {
T t = i / a, x = a;
a = i % x;
i = x;
x = d;
d = v - t * x;
v = x;
}
return (v + n) % n;
}
long long modpow(long long n, long long k, long long mod) {
long long ans = 1;
while (k > 0) {
if (k & 1) ans = (ans * n) % mod;
k >>= 1;
n = (n * n) % mod;
}
return ans % mod;
}
template <class T>
string str(T Number) {
string Result;
ostringstream convert;
convert << Number;
Result = convert.str();
return Result;
}
int StringToNumber(const string &Text) {
istringstream ss(Text);
int result;
return ss >> result ? result : 0;
}
template <class T>
inline vector<pair<T, int> > FACTORISE(T n) {
vector<pair<T, int> > R;
for (T i = 2; n > 1;) {
if (n % i == 0) {
int C = 0;
for (; n % i == 0; C++, n /= i)
;
R.push_back(make_pair(i, C));
}
i++;
if (i > n / i) i = n;
}
if (n > 1) R.push_back(make_pair(n, 1));
return R;
}
template <class T>
inline T TOTIENT(T n) {
vector<pair<T, int> > R = FACTORISE(n);
T r = n;
for (int i = 0; i < R.size(); i++) r = r / R[i].first * (R[i].first - 1);
return r;
}
template <class T>
inline T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
double rnd(float d) { return floor(d + 0.49); }
int main() {
int a, m;
cin >> a >> m;
int x = gcd(a, m);
set<int> ans;
int flag = 0;
long long sum = a;
while (1) {
sum = sum + sum % m;
if (sum % m == 0) {
flag = 1;
break;
}
if (ans.find(sum % m) != ans.end()) break;
ans.insert(sum % m);
}
if (flag == 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
long long a, m;
int main() {
scanf("%lld%lld", &a, &m);
int sum = 0;
while (sum <= 1e7) {
if (a % m == 0) return 0 * puts("Yes");
a = a + a % m;
sum++;
}
puts("No");
}
|
### 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;
const int N = 1010;
long long a, m;
int main() {
scanf("%lld%lld", &a, &m);
int sum = 0;
while (sum <= 1e7) {
if (a % m == 0) return 0 * puts("Yes");
a = a + a % m;
sum++;
}
puts("No");
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int a, m, rem = 0;
int temp, flag = 0;
cin >> a >> m;
temp = a;
rem = temp % m;
int first = rem;
for (int i = 0; i <= 100; i++) {
temp += rem;
rem = temp % m;
if (rem == 0) {
cout << "Yes\n";
return 0;
} else if (rem == first) {
cout << "No\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;
int main() {
ios_base::sync_with_stdio(false);
int a, m, rem = 0;
int temp, flag = 0;
cin >> a >> m;
temp = a;
rem = temp % m;
int first = rem;
for (int i = 0; i <= 100; i++) {
temp += rem;
rem = temp % m;
if (rem == 0) {
cout << "Yes\n";
return 0;
} else if (rem == first) {
cout << "No\n";
return 0;
}
}
cout << "No\n";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
for (int a, m; cin >> a >> m;) {
long long prod = a;
map<long long, int> used;
while (prod % m != 0 && prod > 0) {
prod = (prod + prod) % m;
if (used[prod]) break;
used[prod] = 1;
}
if (prod % m == 0 || prod < 0)
cout << "Yes" << endl;
else
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() {
for (int a, m; cin >> a >> m;) {
long long prod = a;
map<long long, int> used;
while (prod % m != 0 && prod > 0) {
prod = (prod + prod) % m;
if (used[prod]) break;
used[prod] = 1;
}
if (prod % m == 0 || prod < 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
;
}
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";
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 a, b;
cin >> a >> b;
while (a % 2 == 0) a /= 2;
while (b % 2 == 0) b /= 2;
if (a % b == 0)
cout << "Yes";
else
cout << "No";
return 0;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long i, j, k, m, n, t, x, a;
cin >> a >> m;
map<long long, long long> mym;
long long rem = a % m;
bool paisi = false;
while (mym[rem] == 0) {
mym[rem]++;
a = a + rem;
rem = a % m;
if (rem == 0) {
paisi = true;
break;
}
}
if (paisi)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
|
### 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() {
long long i, j, k, m, n, t, x, a;
cin >> a >> m;
map<long long, long long> mym;
long long rem = a % m;
bool paisi = false;
while (mym[rem] == 0) {
mym[rem]++;
a = a + rem;
rem = a % m;
if (rem == 0) {
paisi = true;
break;
}
}
if (paisi)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
```
|
#include <bits/stdc++.h>
using namespace std;
int a, m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> a >> m;
for (int i = 1; i <= 10000000; i++) {
a = (a + a) % m;
if (a == 0) {
cout << "Yes";
return 0;
}
}
cout << "No";
}
|
### 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 a, m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> a >> m;
for (int i = 1; i <= 10000000; i++) {
a = (a + a) % m;
if (a == 0) {
cout << "Yes";
return 0;
}
}
cout << "No";
}
```
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.