#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std ;
#define pf printf
#define sf scanf
#define loop(i, n) for(i=0; i<n; i++)
#define MAX 500
int main()
{
int a, m, i, rem;
while(sf("%d%d", &a, &m)==2)
{
loop(i, MAX)
{
rem = (a%m);
if(rem==0)
break;
a+=rem;
}
if(rem==0)
pf("Yes\n");
else
pf("No\n");
}
return 0;
}
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std ;
#define pf printf
#define sf scanf
#define loop(i, n) for(i=0; i<n; i++)
#define MAX 500
int main()
{
int a, m, i, rem;
while(sf("%d%d", &a, &m)==2)
{
loop(i, MAX)
{
rem = (a%m);
if(rem==0)
break;
a+=rem;
}
if(rem==0)
pf("Yes\n");
else
pf("No\n");
}
return 0;
}
How do you know when to stop? i.e. You set MAX with 500, why not 600 or 300? Thanks
ReplyDelete