Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1795 Accepted Submission(s): 459
Problem Description
从a点b分到s点t分时针和分针重合多少次?
Input
有多组数据,每组1行4个数 a,b,s,t. 1<=a,s <=12, 0<=b,t<60. 0 0 0 0结束.
Output
参看Sample output
Sample Input
12 50 1 2
3 8 3 20
2 45 11 0
11 0 3 20
1 2 12 50
3 20 3 8
0 0 0 0
Sample Output
0
1
8
4
11
10
Author
zhousc
Source
ECJTU 2008 Summer Contest
事实证明,想一些乱七八糟的计算,不如直接把结果列出来方便。
代码如下:
#include <stdio.h>
int main()
{
double h[25]={0,65.45,130.91,196.36,261.82,327.27,392.73,458.18,523.64,589.09,
654.55,720.00,785.45,850.91,916.36,981.82,1047.27,1112.73,1178.18,
1243.64,1309.09,1374.55,1440.00};
int a,b,s,t;
int t1,t2;
int c;
while (~scanf ("%d %d %d %d",&a,&b,&s,&t) && (a||b||s||t))
{
c=0;
t1=a*60+b;
t2=s*60+t;
if (t1>t2)
t2+=720;
for (int i=0;i<=22;i++)
{
if (t1<=h[i] && t2>=h[i])
c++;
}
printf ("%d\n",c);
}
}