Description
老曹和老颜玩游戏,他们准备攻击一个实体,实体有c的血量,老曹可以给实体造成a的伤害,老颜可以给实体造成b的伤害,过关条件是老曹和老颜攻击分别攻击多次之后,实体血量刚好为0。请你判断老曹和老颜是否能过关
Input
输入
输入有多组,
每组数据占一行,有3个整数a, b, c (1 ≤ a, b ≤ 100, 1 ≤ c ≤ 10 000)
Output
输出
每组数据输出占一行,能通关则输出Yes,否则为No
Sample Input
4 6 15
3 2 7
6 11 6
Sample Output
No Yes Yes
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c,maxn,minn; bool p; while(~scanf("%d %d %d",&a,&b,&c)) { p = false; maxn = max(a,b); minn = min(a,b); while(c > 0) { if(c % maxn ==0 || c % minn == 0) { p = true; break; } c -= maxn; } if(p) cout<<"Yes"<<endl; else cout<<"No"<<endl; } return 0; }