zoukankan      html  css  js  c++  java
  • POJ2210 Metric Time

    Metric Time
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 2369   Accepted: 738

    Description

    The Metric Time is one of the most important points of PSOS Election Programme. The Time can be much easier calculated in operating systems. These systems are then more stable, which meets the main goal of the Party.

    The length of one day is the same as with the "classic" time. The day is divided into 10 metric hours, each of them into 100 metric minutes, and each minute into 100 metric seconds. 10 metric days form one metric week, 10 metric weeks give one metric month, 10 metric months are called metric year. It is obvious this Metric Time is much better than the classic one.

    Some opponent parties often complain that the Metric Time has also some drawbacks. First of all, it would be very difficult to change to the new time. PSOS Chairman decided to solve these problems all at once. He plans to publish a freeware utility which will be able to convert between the time formats. Your goal is to write one half of this utility, the program which converts classic time to Metric Time. Metric hours, metric minutes, and metric seconds are counted starting with zero, as usual. Metric days and metric months start with one. There exist metric year zero. The metric seconds should be rounded to the nearest smaller integer value. Assume that 0:0:0 1.1.2000 classic time is equal to 0:0:0 1.1.0 Metric Time.

    Note that the classic year is leap, if it is an integer multiple of 4. The only exception are years divisible by 100 - they are leap only if they are an integer multiple of 400. For example, leap years are 1996, 2400, and 2000; leap years are not 1900, 2300, 2002.

    Input

    At the first line there is a positive integer N stating the number of assignments to follow. Each assignment consists of exactly one line in the form "hour:minute:second day.month.year" which is the date in the classic form (usual in most of European countries). The date is always valid, 2000 <= year <= 50000.

    Output

    The program must print exactly one line for each assignment. The line should have the form "mhour:mmin:msec mday.mmonth.myear" which is the Metric Time equal to the specified classic time.

    Sample Input

    7
    0:0:0 1.1.2000
    10:10:10 1.3.2001
    0:12:13 1.3.2400
    23:59:59 31.12.2001
    0:0:1 20.7.7478
    0:20:20 21.7.7478
    15:54:44 2.10.20749
    

    Sample Output

    0:0:0 1.1.0
    4:23:72 26.5.0
    0:8:48 58.2.146
    9:99:98 31.8.0
    0:0:1 100.10.2000
    0:14:12 1.1.2001
    6:63:0 7.3.6848
    
     1 /* 功能Function Description:  POJ-2210 Metric Time   
     2    开发环境Environment:       DEV C++ 4.9.9.1
     3    技术特点Technique:
     4    版本Version:
     5    作者Author:                可笑痴狂
     6    日期Date:                  20120726
     7    备注Notes:                 主要是日期的处理和题意的理解
     8 */
     9 #include<stdio.h>
    10 #include<string.h>
    11 char s1[10],s2[20];
    12 int hour,min,sed,year,month,day;
    13 int table[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    14 
    15 void init()             //初始化分离出日期
    16 {
    17     int i;
    18     for(i=0;s1[i]!=':';++i)
    19         hour=hour*10+s1[i]-'0';
    20     for(++i;s1[i]!=':';++i)
    21         min=min*10+s1[i]-'0';
    22     for(++i;s1[i]!='\0';++i)
    23         sed=sed*10+s1[i]-'0';
    24 
    25     for(i=0;s2[i]!='.';++i)
    26         day=day*10+s2[i]-'0';
    27     for(++i;s2[i]!='.';++i)
    28         month=month*10+s2[i]-'0';
    29     for(++i;s2[i]!='\0';++i)
    30         year=year*10+s2[i]-'0';
    31 }
    32 
    33 int judge(int i)                 //判断闰年
    34 {
    35     if(i%400==0||i%4==0&&i%100)
    36         return 1;
    37     return 0;
    38 }
    39 
    40 int main()
    41 {
    42     int n,i,sumday,sumsed;
    43     int nsed,nmin,nhour,nday,nmonth,nyear;
    44     scanf("%d",&n);
    45     while(n--)
    46     {
    47         hour=min=sed=year=month=day=0;
    48         sumday=0;
    49         scanf("%s%s",s1,s2);
    50         init();
    51 
    52         for(i=2000;i<year;++i)     //先计算出现实中距离1.1.2000的总天数
    53         {
    54             if(judge(i))
    55                 sumday+=366;
    56             else
    57                 sumday+=365;
    58         }
    59         for(i=1;i<month;++i)
    60             sumday+=table[i-1];
    61         if(month>2&&judge(year))
    62             sumday++;
    63         sumday+=day-1;           
    64                                   
    65         nyear=sumday/1000;          //根据题意,现实中的一天与题目中规定的一天时间是相等的
    66         nmonth=(sumday%1000)/100;
    67         nday=sumday%100;
    68 
    69         sumsed=hour*3600+min*60+sed;
    70         sumsed=sumsed*125/108;    //转化为题目中的秒数
    71 
    72         nhour=sumsed/10000;
    73         nmin=(sumsed%10000)/100;
    74         nsed=sumsed%100;
    75         
    76         printf("%d"":""%d"":""%d ""%d"".""%d"".""%d\n",nhour,nmin,nsed,nday+1,nmonth+1,nyear);
    77     }
    78     return 0;
    79 }
    功不成,身已退
  • 相关阅读:
    安装jdk1.8导致eclipse显示问题
    Linux创建定时任务
    Burp suite抓取HTTPS请求
    Webbench性能测试
    Fiddler抓取手机Https请求
    Linux下使用Jmeter做性能测试
    Charles抓取手机https请求
    Jmeter发送Java请求
    Linux搭建JDK、Tomcat安装及配置
    Loadrunner监控Apache
  • 原文地址:https://www.cnblogs.com/dongsheng/p/2609906.html
Copyright © 2011-2022 走看看