题解 | #不找零钱#

不找零钱

https://ac.nowcoder.com/acm/problem/22214

using namespace std;
#define int long long
#define endl '\n'
signed main(){
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c;cin>>a>>b>>c;int flag=0;
    for(int x=0;x*a<=c;x++){
        for(int y=0;y*b<=c;y++){
            if(a*x+b*y==c)
            {
                flag++;//找到符合的一种方法之后记录,不用立马输出“yes",这样会有多个多个Yes。循环退出之后再输出
            }
        }
    }
    if(flag==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务