ACM:N: 就多了两分钟

xiaoxiao2021-02-27  221

ACM:N: 就多了两分钟

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 注意:输出"Day #: "有空格,不要漏了。 #include <iostream>#include <cstdio>#include <cstring>#include <vector>#include <cmath>#include <algorithm>#include <string>#include <ctime>#define LL long long#define MAX(a,b)((a)>(b)?a:b)#define MIN(a,b)((a)<(b)?a:b)#define INF 0x7ffffff#define N 1005#define M 15using namespace std;int main(){ int h1,m1,h2,m2; int day=1; int num; int w,v; while(scanf("%d%d%d%d",&h1,&m1,&h2,&m2)!=EOF) { printf("Day %d: ",day++); if(h1>h2) printf("Joking\n"); else if(h1==h2&&m1>m2) printf("Joking\n"); else { num=(h2-h1)*60+m2-m1; w=num/30; v=num%30; if(v) { w++; v=30-v; } printf("%d %d\n",w,v); } } return 0;}
转载请注明原文地址: https://www.6miu.com/read-12874.html

最新回复(0)