当前位置:首页 > 开发 > 编程语言 > 编程 > 正文

poj2210 - Metric Time

发表于: 2013-11-26   作者:空城旧梦why   来源:转载   浏览:
ACM
摘要: Metric Time Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2584   Accepted: 796 Description The Metric Time is one of the most important points of PSOS Ele
Metric Time
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2584   Accepted: 796

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

Source

 
按照题目意思直接转化就行,注意优化不然有可能会超时
 
#include<cstdio>
using namespace std;
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
    int day,month,year,h,minu,sec,mday,mmonth,myear,mh,mminu,msec,days,y,secs,cas;
//    freopen("in.txt","r",stdin);
    scanf("%d",&cas);
    while(cas--)
    {
        scanf("%d:%d:%d %d.%d.%d",&h,&minu,&sec,&day,&month,&year);
        days=0;
        for(y=2000;y<year;y+=4) //这里y不要每次加1不然会超时
         {
            if((y%100==0&&y%400==0)||(y%4==0&&y%100!=0))
                days+=1;
        }
        for(int i=1;i<month;i++)
            days+=m[i];
        if(month>2&&((year%100==0&&year%400==0)||(year%4==0&&year%100!=0)))
            days+=1;
        days+=(day-1);
        days+=(365*(year-2000));
        myear=days/1000;
        days%=1000;
        mmonth=days/100;
        days%=100;
        mday=days;
        secs=h*3600+minu*60+sec;
        secs*=125;
        secs/=108;
        mh=secs/10000;
        secs-=10000*mh;
        mminu=secs/100;
        secs-=100*mminu;
        msec=secs;
        printf("%d:%d:%d %d.%d.%d\n",mh,mminu,msec,mday+1,mmonth+1,myear);
    }
    return 0;
}

poj2210 - Metric Time

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
Metric的引入主要为了实现proactive(积极、主动)维护数据库: 在EM中可以对Metrics进行管理: 在这
METRIC=(BW+DELAY)*256 BW=10^7/最小带宽(小数点部分省略,取整) DELAY=延迟总和/10 256:放大因
如下拓扑: 在R1上: Router>enable Router#config t Router(config)#hostname R1 R1(config)#in
原文出处:http://blog.csdn.net/kiki113/article/details/4033017 python 的内嵌time模板翻译及说
time模块 time常用函数 最近参与python的一个项目,发现经常遇到一些常用的模块,而每次使用时,我
import time >>> time.strftime("%Y-%m-%d %H:%M:%S") '2013-11-07 14:23:02' 1.python获取
一、三个概念: (1)UTC/GMT:Coorainated Universal Time:它是一个标准,最主要的世界时间标准,
Time.h class Time { public : void set_time (); void show_time (); inline void add_a_sec (); i
import time # time.asc time()将元组转换为字符串;如果指定元组,则转换为响应的字符串 不指定元
http://qinxuye.me/article/details-about-time-module-in-python/ 在平常的代码中,我们常常需要与
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号