• CF633A Ebony and Ivory


    CF633A Ebony and Ivory

    洛谷传送门

    题意翻译

    给定三个数a,b,c 判断不定方程 a * x + b * y == c 是否有整数解。存在输出“Yes”,否则为“No”。 @yyy2015c01

    翻译提供者:龙_之_谷


    题解:

    一般这种题都是枚举一个未知量判第二个未知量是不是整数。

    重点有三:

    第一:确定拿谁表示谁。

    第二:确定枚举范围。

    第三:确定判断条件。

    剩下的就直接做就好了。

    代码:

    #include<cstdio>
    #include<algorithm>
    #include<iostream>
    using namespace std;
    int a,b,c;
    char nmsl[6];
    int main()
    {
    	// freopen("yesterday.in","r",stdin);
    	// freopen("yesterday.out","w",stdout);
    	scanf("%d%d%d",&a,&b,&c);
    	int mx=max(a,b);
    	int mxx=c/mx+1;
    	for(int i=0;i<=mxx;i++)
    	{
    		int p=i*mx;
    		if(p>c)
    			break;
    		if((c-p)%(a+b-mx)==0)
    		{
    			puts("Yes");
    			return 0;
    		}
    	}
    	puts("No");
    	return 0;
    }
    
  • 相关阅读:
    jsoup使用选择器语法来查找元素
    获取MD5值
    MD5
    反射机制的实现代码
    struts
    spring
    Hibernate
    商品信息录入
    extjs
    EasyUI
  • 原文地址:https://www.cnblogs.com/fusiwei/p/14020011.html
Copyright © 2020-2023  润新知