Input is given from Standard Input in the following format:
S T X
Output
If the light is on at 30 minutes past X o'clock, print Yes; otherwise, print No.
Sample Input 1
72012
Sample Output 1
Yes
The light is on between 7 o'clock and 20 o'clock. At 30 minutes past 12 o'clock, it is on, so we print Yes.
Sample Input 2
20712
Sample Output 2
No
The light is on between 0 o'clock and 7 o'clock, and between 20 o'clock and 0 o'clock (on the next day). At 30 minutes past 12 o'clock, it is off, so we print No.
Sample Input 3
23023
Sample Output 3
Yes
WA:
/* ----- atcoder 11.20 --------
----------- A.on and off --------------
*/#include<bits/stdc++.h>usingnamespace std;intmain(){
std::ios_base::sync_with_stdio(false);int s, t, a;
cin >> s >> t >> a;int res;if(s <= t){
res = t - s;}else{if(t ==0)
res =48- s + t;else
res =24- s + t;}//cout << res << endl;if(res > a)
cout <<"Yes"<< endl;else
cout <<"No"<< endl;return0;}
AC:
#include<bits/stdc++.h>usingnamespace std;intmain(){double s, t, x;
cin >> s >> t >> x;
x +=0.5;
string ans ="Yes";if(s < t){if(x < s || x > t) ans ="No";}else{if(x < s && x > t) ans ="No";}
cout << ans << endl;}
Time Limit: 2 sec / Memory Limit: 1024 MBScore : 100 pointsInputInput is given from Standard Input in the following format:S T XOutputIf the light is on at 30 minutes past X o'clock, print Yes; otherwise, print No.Sample Input 17 20 12Sa.