CSUOJ 1087 就多了两分钟

Description

 Yucept21和他的室友Zyn因为宿舍没电去网吧上网,上了27分钟,Cs打电话来说来电了。所以Yucept21在第29分钟下机了,上网的费用是一块钱,然后Zyn墨迹了两分钟,第31分钟下机,上机费用是2元。现在知道网吧是按照半个小时计费的,假设半个小时上机的费用是1块钱。现在给你两个时间点,要你求出上机费用和再上多少分钟最划算?(最划算是指上满这个三十分钟,比如上机一个小时四十五分钟,那么再上v = 15分钟最划算)。

Input

 输入为一行四个数字,上机时间h1,m1,下机时间h2,m2。 h是小时,m是分钟,采用24小时制。0<=h1,h2<=23

0<=m1,m2<60 

Output

 输出Day #: 后面两个数字w和v,w为费用,v描述如上,单位分钟。如果上机时间在下机时间的后面则输出"Joking"。

Sample Input

1 48 3 39
20 16 22 6
23 8 1 42

Sample Output

Day 1: 4 9
Day 2: 4 10
Day 3: Joking

Hint

#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int h1, m1, h2, m2;
	int cas = 0;
	int t, cnt,last;
	while (cin >> h1 >> m1 >> h2 >> m2)
	{
		printf("Day %d: ", ++cas);
		if (h1>h2 || h1 == h2&&m1>m2)
		{
			cout << "Joking" << endl;
			continue;
		}
		t = (h2 - h1) * 60 + m2 - m1;
		cnt = t / 30;
		last = t % 30;
		if (last)
			last = 30 - t % 30;
		if (last != 0 && last != 30)
			cnt++;

		cout << cnt << " " << last << endl;
	}
	return 0;
}
/**********************************************************************
	Problem: 1087
	User: leo6033
	Language: C++
	Result: AC
	Time:64 ms
	Memory:2024 kb
**********************************************************************/


猜你喜欢

转载自blog.csdn.net/leo6033/article/details/80244115
今日推荐