First Date

First Date
Time Limit: 3000ms, Special Time Limit:7500ms,Memory Limit:65536KB
Total submit users: 81, Accepted users:52
Problem 12952 : No special judgement
Problem description

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
1582-10-04
1752-09-02
1900-02-25
1923-02-15
Sample Output
1582-10-15
1752-09-14
1900-03-10
1923-03-01
Problem Source
NWERC 2013

/*

题目:F:First Date
题意:J 历规则:能被4整除为闰年 G 历规则:能被4整除但不能被100整除为闰年,或者能被400整除也为闰年。 给出 J 历的日期 求对应 G 历的日期
思路:求出给的年份的前一年两种日历相差的天数x,然后计算给出日期的年份过去的天数y,总天数z=x+y,然后将总天数z分给给出的年份。
感想:比赛时看四个小时的题目就是没看懂,英语实在太差。赛后知道题意后做了,一开始由于最后一年需要特殊处理而且情况比较复杂也容易糊涂所以一直WA。最后改了处理的方法,基本上不需要去怎么特殊处理,也很容易懂,所以才贴出来。这里我是按天分下去的还可以优化下按月分下去。

*/

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<iterator>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long
#define inf 1<<29
int day[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };   //  不是闰年
int day1[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };  //  闰年
int fun(int x)
{
	int a = 0, b = 0;
	a = x / 4 - 1582 / 4;
	b = (x / 4 - x / 100 + x / 400) - (1582 / 4 - 1582 / 100 + 1582 / 400);
	return a - b + 11;
}
int fun1(int a, int b, int c)
{
	int x = 0;
	if (a % 4 == 0)    //  a是闰年
	{
		for (int i = 1; i < b; i++) x += day1[i];		
		x += c;
	}
	else              //	a不是闰年
	{
		for (int i = 1; i < b; i++) x += day[i];		
		x += c;
	}
	return x;
}
int main()
{
	int a, b, c;
	while (scanf("%d-%d-%d", &a, &b, &c) != EOF)
	{
		int x = 0, y = 0;
		x = fun(a - 1);	     //  前 a-1  年产生的日期差
		y = fun1(a, b, c);   //  求出 a 年过去了的天数
		x += y;
		b = 1; c = 0;
		for (int i = 1; i <= x; i++)  // 按 G 历将天数分给a年
		{
			if ((!(a % 4) && (a % 100)) || !(a % 400))  //  闰年
			{
				if (c == day1[b])
				{
					if (b == 12)  ++a, b = 1, c = 1;
					else ++b,c = 1;
				}
				else c++;
			}
			else   //  不是闰年
			{
				if (c == day[b])
				{
					if (b == 12) ++a, b = 1, c = 1;
					else ++b,c = 1;
				}
				else c++;
			}
		}
		printf("%d-%02d-%02d\n", a, b, c);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的纺织品企业财务管理系统,源码+数据库+毕业论文+视频演示 在如今社会上,关于信息上面的处理,没有任何一个企业或者个人会忽视,如何让信息急速传递,并且归档储存查询,采用之前的纸张记录模式已经不符合当前使用要求了。所以,对纺织品企业财务信息管理的提升,也为了对纺织品企业财务信息进行更好的维护,纺织品企业财务管理系统的出现就变得水到渠成不可缺少。通过对纺织品企业财务管理系统的开发,不仅仅可以学以致用,让学到的知识变成成果出现,也强化了知识记忆,扩大了知识储备,是提升自我的一种很好的方法。通过具体的开发,对整个软件开发的过程熟练掌握,不论是前期的设计,还是后续的编码测试,都有了很深刻的认知。 纺织品企业财务管理系统通过MySQL数据库与Spring Boot框架进行开发,纺织品企业财务管理系统能够实现对财务人员,员工,收费信息,支出信息,薪资信息,留言信息,报销信息等信息的管理。 通过纺织品企业财务管理系统对相关信息的处理,让信息处理变的更加的系统,更加的规范,这是一个必然的结果。已经处理好的信息,不管是用来查找,还是分析,在效率上都会成倍的提高,让计算机变得更加符合生产需要,变成人们不可缺少的一种信息处理工具,实现了绿色办公,节省社会资源,为环境保护也做了力所能及的贡献。 关键字:纺织品企业财务管理系统,薪资信息,报销信息;SpringBoot
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值