平分巧克力

n名儿童希望将m块相同的巧克力糖分成份量相等的n堆,规定每块巧克力糖至多能被分成两部分。 问对怎样的n和m,所述要求能实现?

Input

n和m。 (1<=n<=1000,1<=m<=1000)

Output

如果能,则输出Yes,否则输出No。

Sample Input

7 9
12 9
11 9

Sample Output

Yes
Yes
No
#include<bits/stdc++.h>
using namespace std;
long long n,m;
bool f;
int main()
{
	while(scanf("%d %d",&n,&m)!=EOF)
	{
	    if(n<=m)
        {
            f=true;
        }
        else
        {
            f=n==m+__gcd(n,m);
        }
        if(f)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44061561/article/details/94589280