• CSU L: 就多了两分钟


    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

    • 题解:
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <vector>
    #include <set>
    #include <map>
    using namespace std;
    
    int main()
    {
        int h1,m1,h2,m2;
        int cnt=0;
        while(~scanf("%d%d%d%d",&h1,&m1,&h2,&m2)){
            int w=0,v=0;
            int minute=h2*60+m2-h1*60-m1;
            cnt++;
            if(minute<0){
                printf("Day %d: Joking
    ",cnt);
                continue;
            }
            w=(minute)/30;
            if(minute%30!=0)
                w++;
            for(int i=0;i<=30;i++){
                if((minute+i)%30==0){
                    v=i;
                    break;
                }
            }
            printf("Day %d: %d %d
    ",cnt,w,v);
        }
        return 0;
    }
    

  • 相关阅读:
    mongo
    CSS常用属性
    nginx-proxy_cache缓存
    nginx防盗链
    oracle11g-centos部署
    VLAN高级特性
    路由
    网络摄像头分辨率
    前端开发调试线上代码的两款工具
    sql中 in , not in , exists , not exists效率分析
  • 原文地址:https://www.cnblogs.com/kzbin/p/9205218.html
Copyright © 2020-2023  润新知