304776: CF911C. Three Garlands

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Three Garlands

题意翻译

题意 圣诞树上有三个花环,Mishka将开启这些花环。 有时候花环会亮,有时候不会。如果第i个花环在第x秒开启,则仅在以第x,x+ki,x+2*ki……秒时是亮的。 Mishka想要打开花环,以便在每秒至少有一个点亮的花环。 在米什卡想要选择三个整数x1,x2,x3,以便在第x1秒期间接通第一个花环,在第x2秒期间接通第二个花环,并且在第x3秒期间接通第三个花环, 并且在从max(x1,x2,x3)开始的每秒中,至少一个花环将被点亮。 帮助米什卡告诉她是否有可能做到这一点。 输入 一行,3个整数,k1,k2,k3。(1<=k1,k2,k3<=1500) 输出 一行,若可以输出“YES”,不可以则输出“NO”(不包括引号) 样例解释 在第一例中,则可选择x1=1,x2=2,x3=1。 第一个花环将在第1,3,5,7,…秒是亮着的。 第二个花环将在第2,4,6,8,…秒是亮着的。 第三个花环将在第1,4,7,10,…秒是亮着的。 根据题意,在第2秒后,每秒都将有灯亮着,输出 YES 。 在第二例中,无解,输出 NO 。 Translated by@KethGeorge

题目描述

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+k_{i} $ , $ x+2k_{i} $ , $ x+3k_{i} $ 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 $ x_{1} $ , $ x_{2} $ and $ x_{3} $ (not necessarily distinct) so that he will switch on the first garland during $ x_{1} $ -th second, the second one — during $ x_{2} $ -th second, and the third one — during $ x_{3} $ -th second, respectively, and during each second starting from $ max(x_{1},x_{2},x_{3}) $ at least one garland will be lit. Help Mishka by telling him if it is possible to do this!

输入输出格式

输入格式


The first line contains three integers $ k_{1} $ , $ k_{2} $ and $ k_{3} $ ( $ 1<=k_{i}<=1500 $ ) — time intervals of the garlands.

输出格式


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.

输入输出样例

输入样例 #1

2 2 3

输出样例 #1

YES

输入样例 #2

4 2 3

输出样例 #2

NO

说明

In the first example Mishka can choose $ x_{1}=1 $ , $ x_{2}=2 $ , $ x_{3}=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 $ x_{3} $ 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.

Input

题意翻译

题意 圣诞树上有三个花环,Mishka将开启这些花环。 有时候花环会亮,有时候不会。如果第i个花环在第x秒开启,则仅在以第x,x+ki,x+2*ki……秒时是亮的。 Mishka想要打开花环,以便在每秒至少有一个点亮的花环。 在米什卡想要选择三个整数x1,x2,x3,以便在第x1秒期间接通第一个花环,在第x2秒期间接通第二个花环,并且在第x3秒期间接通第三个花环, 并且在从max(x1,x2,x3)开始的每秒中,至少一个花环将被点亮。 帮助米什卡告诉她是否有可能做到这一点。 输入 一行,3个整数,k1,k2,k3。(1<=k1,k2,k3<=1500) 输出 一行,若可以输出“YES”,不可以则输出“NO”(不包括引号) 样例解释 在第一例中,则可选择x1=1,x2=2,x3=1。 第一个花环将在第1,3,5,7,…秒是亮着的。 第二个花环将在第2,4,6,8,…秒是亮着的。 第三个花环将在第1,4,7,10,…秒是亮着的。 根据题意,在第2秒后,每秒都将有灯亮着,输出 YES 。 在第二例中,无解,输出 NO 。 Translated by@KethGeorge

加入题单

上一题 下一题 算法标签: