您的位置:首页 > 其它

FZU 1783 Strange Clock

2009-08-03 17:10 183 查看
Strange Clock

Time Limit:1sMemory limit:32M
Accepted Submit:44Total Submit:92

Problem Description

There is a strange clock, without any number written. Can you tell me what time it is now, based on the angle of the hour hand?

When the hour hand points right (0 degree), it is 3 o’clock. When it points to 80 degrees, it’s between 0 o’clock and 1 o’clock. Note that there is no 12 o’clock. You should always write 0 o’clock instead.

Input

There are at most 10 test cases. Each case contains a single integer a (0 ≤ a < 360), the angle of the hour hand. The input ends with a = -1.

OutPut

For each test case, print the current time, in one of the following format: - Exactly x o’clock - Between x o’clock and y o’clock Note that, in the second format, x o’clock should be exactly one hour before y o’clock, So you cannot write something like “Between 3 o’clock and 2 o’clock”.

Sample Input

90
245
-1

Sample Output

Exactly 0 o'clock
Between 6 o'clock and 7 o'clock

Original: 2009 NIT Cup National Invitation Contest

解题:

一开始依旧被表给晕了。注意看图。上面的数字就是时间。90度为0点,60度为1点,0度为3点,330度为4点···

#include <iostream>
using namespace std;

int main()
{
	int n,i,j;
	int degrees[13]={90,60,30,0,330,300,270,240,210,180,150,120,90};	
	while (cin>>n && n!=-1)
	{
		if (n%30==0)
		{
			for (i=0;i<12;i++)
			{
				if (degrees[i]==n)
				{
					cout<<"Exactly "<<i<<" o'clock"<<endl;
					break;
				}
			}
		}
		else
		{
			for (i=0;i<12;i++)
			{
				if (degrees[i]>n && degrees[i+1]<n)
				{
					cout<<"Between "<<i<<" o'clock and ";
					if (i+1==12)
					{
						i=-1;
					}
					cout<<i+1<<" o'clock"<<endl;
					break;
				}
			}

		}
	}
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: