UESTC 893 First Date 计算时间


First Date

Time Limit: 5678/1234MS (Java/Others)     Memory Limit: 65432/65432KB (Java/Others)
 

In 1582, pope Gregory XIII decreed a calendar reform to bring the mean length of the calendar year (counted in days) more in line with the actual number of days in an astronomical year. This calendar reform entailed a transition from the Julian calendar to the Gregorian calendar.

Both the Julian and Gregorian calendars have regular years with 365 days, and so-called leap years with 366 days. In regular years, the month February has 28 days, while in leap years, it has an extra leap day: February 29th.

The single difference between the Julian and Gregorian calendars is in their rule to determine if a year is a leap year. In the Julian calendar, leap years are those years that are divisible by~4. The Gregorian calendar's rule for determining leap years is a bit more complicated: years divisible by 4 are leap years, unless they are divisible by 100 but not by 400.

Following these rules, the years 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, and 2400 are all leap years in the Julian calendar. In the Gregorian calendar, the only leap years in this list are 1600, 2000, and 2400.

The old Julian calendar has a mean year length of 365.25 days, while the new Gregorian calendar has a mean year length of 365.2425 days. Given that the actual number of days in an astronomical year is about 365.24219 days, you can see why the Gregorian calendar is an improvement.

As part of the Gregorian reform, a number of dates were skipped, to reverse the effects of having used the Julian calendar for over 1500 years. Specifically, the Gregorian reform decreed that October~4, 1582 (Julian) was to be followed by October~15, 1582 (Gregorian).

However, by the end of the 16th century the Reformation was in full swing. While the Catholic countries tended to follow the Papal decree, many countries continued using the Julian calendar until much later. For example, the United Kingdom switched from the Julian calendar to the Gregorian calendar on September~2, 1752 (Julian) which was followed by September~14, 1752 (Gregorian) --- by that time, 11 dates had to be skipped to make the switch. The last European country to switch was Greece, which made the transition as late as February~15, 1923 (Julian) which was followed by March~1, 1923 (Gregorian), skipping 13 dates.

Given the last day for which the Julian calendar is in effect for some country (expressed as a Julian date), determine the next day's Gregorian date, i.e., the first date that uses the Gregorian calendar.

Input

For each test case, the input consists of one line containing a date in the Julian calendar, formatted as YYYY-MM-DD. This date will be no earlier than October~4, 1582, and no later than October~18, 9999. The given date represents the last day that the Julian calendar is in effect for some country.

Output

For each test case, print the first Gregorian date after the calendar transition.

Sample input and output

Sample Input Sample Output
1582-10-04
1752-09-02
1900-02-25
1923-02-15
1582-10-15
1752-09-14
1900-03-10
1923-03-01

Source

Northwestern European Regional Contest 2013

求出给出的年份增加的天数n,在此年份上增加n就是所求。
//800 KB	191 MS
#include<stdio.h>
int judge(int x,int y)
{
    if(x==1||x==3||x==5||x==7||x==8||x==10||x==12)return 31;
    if(x==4||x==6||x==9||x==11)return 30;
    if(x==2&&((y%4==0&&y%100!=0)||(y%400==0)))return 29;
    return 28;
}
int main()
{
    int y,m,d;
    while(scanf("%d-%d-%d",&y,&m,&d)!=EOF)
    {
        int ans=d;
        if(y%400!=0&&y%100==0&&m>2)ans++;
        for(int i=100; i<=y-1; i+=100)
            if(i%400!=0)ans++;
        ans--;
        while(ans>judge(m,y))
        {
            ans-=judge(m,y);
            m++;
            if(m==13){y++; m=1;}
        }
        printf("%d-%02d-%02d\n",y,m,ans);
    }
    return 0;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
互联网络程序设计是指在互联网上进行程序开发和设计的过程。UESTC则是我国的一所著名高校——电子科技大学。 互联网络程序设计 uestc包含了两个主要的方面:互联网络和程序设计。互联网络是指将多个计算机网络通过通信链路互相连接起来,实现信息共享和资源共享的网络系统。程序设计是指根据需求和目标,通过编写代码和设计算法,实现计算机程序的过程。 互联网络程序设计 uestc的学习内容主要包括以下几个方面: 1. 网络知识:学习互联网络的基本概念、原理和协议,如TCP/IP协议、HTTP协议等。掌握网络编程的基本技术,能够编写网络应用程序。 2. 数据通信:学习数据通信的基本原理和技术,包括数据传输的方式、数据压缩和加密等。了解网络安全和数据保护的基本知识。 3. 程序设计:学习编程语言和开发工具,如Java、C++和Python等。掌握常用的编程技巧和方法,能够设计和实现复杂的网络应用程序。 4. Web开发:学习Web开发的基本知识和技术,包括HTML、CSS、JavaScript等。能够设计和实现交互式的Web应用程序。 5. 数据库技术:学习数据库的基本原理和技术,如SQL语言和数据库管理系统。能够设计和管理数据库,实现数据的存储和检索。 通过学习互联网络程序设计 uestc,可以掌握互联网应用开发的基本技能,具备设计和实现网络应用程序的能力。这对于目前互联网行业的人才需求来说是非常重要的,也为学生提供了广阔的就业和创业机会。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值