911C. Three Garlands(思维)

Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on.

When a garland is switched on, it periodically changes its state — sometimes it is lit, sometimes not. Formally, if i-th garland is switched on during x-th second, then it is lit only during seconds x, x + ki, x + 2ki, x + 3ki and so on.

Mishka wants to switch on the garlands in such a way that during each second after switching the garlands on there would be at least one lit garland. Formally, Mishka wants to choose three integers x1, x2 and x3 (not necessarily distinct) so that he will switch on the first garland during x1-th second, the second one — during x2-th second, and the third one — during x3-th second, respectively, and during each second starting from max(x1, x2, x3) at least one garland will be lit.

Help Mishka by telling him if it is possible to do this!

Input

The first line contains three integers k1, k2 and k3 (1 ≤ ki ≤ 1500) — time intervals of the garlands.

Output

If Mishka can choose moments of time to switch on the garlands in such a way that each second after switching the garlands on at least one garland will be lit, print YES.

Otherwise, print NO.

Examples
Input
Copy
2 2 3
Output
YES
Input
Copy
4 2 3
Output
NO
Note

In the first example Mishka can choose x1 = 1, x2 = 2, x3 = 1. The first garland will be lit during seconds 1, 3, 5, 7, ..., the second — 2, 4, 6, 8, ..., which already cover all the seconds after the 2-nd one. It doesn't even matter what x3 is chosen. Our choice will lead third to be lit during seconds 1, 4, 7, 10, ..., though.

In the second example there is no way to choose such moments of time, there always be some seconds when no garland is lit.

题意:一共有3盏灯,闪烁时间为分别k1,k2,k3,若开灯时间为x1,x2,x3,则

第1盏灯在x1,x1+k1,x1+2*k1,x1+3*k1  . . .   的时候发光

问能否找到一组x1,x2,x3使得任何1秒都有亮光

#include<bits/stdc++.h>
using namespace std;
int vis[1505];
int main(){
	int k1,k2,k3;
	scanf("%d%d%d",&k1,&k2,&k3);
	vis[k1]++;
	vis[k2]++;
	vis[k3]++;
	if(vis[1]) printf("YES\n"); //如果k1=1, x1=1,x2,x3任意 
	else if(vis[2]>=2) printf("YES\n");//如果k1=2,k2=2,x1=1,x2=2,x3任意 
	else if(vis[3]>=3) printf("YES\n");//如果k1=k2=k3=3 x1=1,x2=2,x3=3 
	else if(vis[2]&&vis[4]>=2) printf("YES\n");//如果k1=2,k2=k3=4,x1=1,x2=2,x3=4
	else printf("NO\n");
	return 0;
} 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值