题解 | #不找零钱#

不找零钱

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

为了更少的循环次数,当 b>ab>a 时将 aabb 交换。

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b) swap(a,b);
    int i=1+c/a;
    while(i--){
        if((c-i*a)%b==0) cout<<"Yes",exit(0);
    }
    cout<<"No";
    return 0;
}
全部评论

相关推荐

02-26 18:25
已编辑
南京大学 算法工程师
点赞 评论 收藏
分享
就用这个吧:支持多益再加一个空气使用费
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务