POJ2210-Metric Time

来源:互联网 发布:python map原理 编辑:程序博客网 时间:2024/06/03 20:21
Metric Time
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2515 Accepted: 772

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

70:0:0 1.1.200010:10:10 1.3.20010:12:13 1.3.240023:59:59 31.12.20010:0:1 20.7.74780:20:20 21.7.747815:54:44 2.10.20749

Sample Output

0:0:0 1.1.04:23:72 26.5.00:8:48 58.2.1469:99:98 31.8.00:0:1 100.10.20000:14:12 1.1.20016:63:0 7.3.6848
题目大意:有一种日历计时系统与我们传统的年月日时分秒不同,但是他的一天和传统的一天一样长,但是一天有10小时,一小时有100分,一分有100秒,一周有10天,一个月10周,一年有10个月,现在给你一个传统的时间,按照两种时间的0:0:0 1.1.2000=0:0:0 1.1.0开始计算,用新的计时系统表示的时间是多少。
分析:还是一般的日期计算问题,综合即可!注意不要直接化成新的秒来计算,那样会溢出或者误差比较大,只有不够一整天的再转化成秒计算。
#include<stdio.h>#include<string.h>int leap[50010];void is_leap(){     int i,j;     memset(leap,0,sizeof(leap));     for(i=2000;i<=50000;i++)     {            if((i%4==0&&i%100!=0)||(i%400==0))                leap[i]=1;            else                leap[i]=0;      }}                           int main(){    int N,a,b,c,d,e,f,i,j,time;    char ch1,ch2,ch3,ch4,ch5;    scanf("%d",&N);    is_leap();    while(N--)    {              scanf("%d%c%d%c%d%c%d%c%d%c%d",&a,&ch1,&b,&ch2,&c,&ch3,&d,&ch4,&e,&ch5,&f);              time=0;              for(i=2000;i<f;i++)//整年的天数和               {                      if(leap[i]) time+=366;                      else time+=365;                        }              for(i=1;i<e;i++)              {                     if(i==1||i==3||i==5||i==7||i==8||i==10||i==12) time+=31;                     else if(i==2)                     {                          if(leap[f])  time+=29;                          else time+=28;                     }                     else time+=30;              }              time+=d-1;  f=time/1000;               time=time%1000;              e=time/100+1;  time=time%100;  d=time+1;  time=(a*3600+b*60+c)*125/108;              a=time/10000;              time=time%10000;              b=time/100;              time=time%100;              c=time;              printf("%d%c%d%c%d%c%d%c%d%c%d\n",a,ch1,b,ch2,c,ch3,d,ch4,e,ch5,f);    }    //system("pause");    return 0;}