First Date
Time Limit: 3000ms, Special Time Limit:7500ms, Memory Limit:65536KB
Total submit users: 77, Accepted users: 46
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

题意:J日历闰年只要被4整除;G日历能被4整除但不能被100整除,或者能被400整除的是闰年;

  先在已知J的日历日期,问你G的日历显示的日期?

表示自己不会算钱,这次连日子都算不好。。。。。。。。。。。。。悲剧!

这次就被黑在这里了。。。。。无语。

题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12952

AC代码:

#include<stdio.h>

void Print(int h,int m,int s)
{
printf("%d",h); if(m>) printf("-%d",m);
else printf("-0%d",m);
if(s>) printf("-%d\n",s);
else printf("-0%d\n",s);
}
int main()
{
int i,j,d;
int sum;
int hh,mm,ss;
int year,mouth,day;
int s1[]= {,,,,,,,,,,,,};
int s2[]= {,,,,,,,,,,,,};
while(~scanf("%d-%d-%d",&hh,&mm,&ss))
{ int fa,fb,fc,fd;
// fa=hh/4;
fb=hh/;
fc=hh/;
fd=fb-fc-;
year=hh;
mouth=mm;
day=ss+fd;
// printf("%d\t%d\t%d\t%d\n",fa,fb,fc,fd);
sum=;
// printf("%d\n",day);
if(year%==&&year%!=&&mm<=)
day--;
for(i=mm; i<; i++)
{
// sum+=s1[i];
if(i==&&((year%==&&year%!=)||year%==))
{
if(day>)
{
day-=;
mouth++;
if(mouth>)
{
mouth=;
i=;
year++;
}
}
else
break;
} else if(day>s1[i])
{
day-=s1[i];
mouth++;
if(mouth>)
{
mouth=;
i=;
year++;
}
}
else
break; }
Print(year,mouth,day);
}
return ;
}

超时,和RE的代码。。。。呜呜,过不了

why?

#include<stdio.h>
#include<string.h> #define ll __int64 int leapj(ll y)
{
if(y%==)
return ;
else
return ;
}
int leapg(ll y)
{
if(((y%==)&&(y%!=))||(y%==))
return ;
else
return ;
} void Print(ll h,ll m,ll s)
{
printf("%I64d",h); if(m>) printf("-%I64d",m);
else printf("-0%I64d",m);
if(s>) printf("-%I64d\n",s);
else printf("-0%I64d\n",s);
}
int main()
{
ll i,j,d;
ll num;
ll hh,mm,ss;
ll HH,MM,SS;
ll s1[]= {,,,,,,,,,,,,};
ll s2[]= {,,,,,,,,,,,,};
ll s3[]= { ,, , , , , , , , ,,,};
while(~scanf("%I64d-%I64d-%I64d",&hh,&mm,&ss))
{
ll a=(hh-)/;
if(leapj(hh)&&(mm==||mm==)&&ss<)
a--; // printf("a %d\n",a); num=(hh-)*+a+;
if(hh>)
{
for(j=;j<mm; j++)
{
num+=s1[j];
}
// if(leapj(hh)&&(mm==2&&ss==29||mm>2))
// num++;
num+=ss;
}
// printf("num %I64d\n",num);
// printf("hh %d\n",hh);
if(hh==&&num<=)
{
for(j=; j<; j++)
{
if(num>s3[j])
{
num-=s3[j];
mm++;
}
else
break;
}
ss+=num;
Print(hh,mm,ss);
} else
{
// num-=365;
// printf("hh %d\n",hh);
HH=; while(num>=)
{
// printf("%I64d\t%d\n",num,hh);
num-=;
if(((HH%==)&&(HH%!=))||(HH%==))
num--;
HH++;
} MM=;
SS=;
// printf("%I64d %I64d\n",num,HH);
if(leapg(HH))
{
for(j=; j<; j++)
{
MM++;
if(num>s2[j])
{
num-=s2[j];
}
else
break;
}
SS=num;
}
else
{
for(j=; j<; j++)
{
MM++;
if(num>s1[j])
{
num-=s1[j];
}
else
break;
}
SS=num;
} Print(HH,MM,SS);
} }
return ;
}

First Date (hnoj12952)日期计算的更多相关文章

  1. js Date 函数方法及日期计算

    js Date 函数方法 var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份 ...

  2. java日期比较,日期计算

    版权声明:本文为楼主原创文章,未经楼主允许不得转载,如要转载请注明来源. 都是常用的日期之间的比较方法,供以后参考. 热身:获取当前时间 SimpleDateFormat df = new Simpl ...

  3. CalendarHelper日期计算工具,各种日期的获取和计算

    今天分享一个日期获取和计算的工具类,这个最初是用在项目中获取每周每月日期用的. <Attention> 之后逛帖子的时候发现了这个专门处理日期的库,java上也有,android上还为了避 ...

  4. php 日期 - 计算2个日期的差值

    /** * 日期-计算2个日期的差值 * @return int */ public function get_difference($date, $new_date) { $date = strto ...

  5. 比较两个date返回日期相差天数

    public static int daydiff(Date fDate, Date oDate) { Calendar aCalendar = Calendar.getInstance(); aCa ...

  6. Javascript扩展String.prototype实现格式金额、格式时间、字符串连接、计算长度、是否包含、日期计算等功能

    <script src="Js/jquery-3.1.1.min.js"></script> <script type="text/java ...

  7. js如何通过末次月经日期计算预产日期

    计算方式有两种 1)直接添加280天 2)添加10月8天(参数传递,可用改成9月7天等) js中引入文件 <script src="js/jquery.min.js"> ...

  8. Date 时间 日期 常用方法函数

    转载自https://www.cnblogs.com/lcngu/p/5154834.html 一.java.util.Date对象用来表示时间,基本方法如下: Date mDate = new Da ...

  9. JAVA中日期转换和日期计算的方法

    日期的格式有很多形式,在使用过程中经常需要转换,下面是各种类型转换的使用例子以及日期计算方法的例子. 一.不同格式日期相互转换方法 public class TestDateConvertUtil { ...

  10. 如何取得SharePoint Timer Job的历史成功数和失败数,并按照日期计算排列

    [问题]. 如何取得SharePoint Timer Job的历史成功数和失败数,并按照日期计算排列 [分析] 管理中心只是罗列了所有job的历史和上一次是否成功,没有关于成功和失败的统计数据 [解决 ...

随机推荐

  1. WPF 斜角border

    最近看了一些科技感UI设计,其中很多的按钮都不是常见的圆角边,而是斜角边.查了一下,wpf中好像没有现成的斜角border,网上也没搜到现成的,于是自己写了点时间做了一个,写的较简单,有一些bug(主 ...

  2. 【译】准备好你求职时候用的 GitHub 账号

    我目前正在招聘,很多人分享了他们的GitHubs个人资料和项目,但是维护得很差,所以我决定为活跃的求职者写一个小指南. 无论是否合理,技术招聘人员倾向于从您的GitHub个人资料中推断出很多关于您的信 ...

  3. [POI2015]LOG(树状数组)

    今天考试考了这题,所以来贡献\([POI2015]LOG\)的第一篇题解.代码略丑,调了快三个小时才调出来\(AC\)代码. 对于这种小清新数据结构题,所以我觉得树状数组才是这道题的正确打开方式. 首 ...

  4. Mac OSX配置XAMP虚拟主机

    在前端工作中,有时候需要配置下环境,这篇文章主要是记录了在wamp中配置虚拟主机 首先需要下载wamp软件和navicat数据库管理软件进行管理,下面默认已经下载好所需软件.并且打开服务. 第一步:把 ...

  5. dubbo+zookeeper注册服务报错问题:No service registed on zookeeper

    2019-04-04 11:23:40,372 ERROR [tomcat-threads--1] (com.bill99.dolphin.controller.ExceptionController ...

  6. centos 安装nginx笔记

    添加nginx 存储库 yum install epel-release 安装 yum install nginx 启动 systemctl start nginx

  7. NoSQL -- Redis使用

    NoSQl简介: ubuntun CTRL+alt+F1 图形切换到命令行 CTRL+alt+F7  命令行切换到图形界面 redis介绍 + 实践 Redis是什么? Redis 安装 edis是当 ...

  8. Linux MBR扇区误删恢复

    目录 1. 引导记录误删恢复 1.1 备份引导记录 1.2 误删引导记录 1.3 恢复引导记录 2. 分区表误删恢复 2.1 备份分区表 2.2 误删分区表 2.3 恢复分区表 如果MBR分区表没了, ...

  9. Linux交换空间和内存不足

    交换空间 交换技术就是将一页内存复制到预先设定的硬盘上的交换空间,来释放该页占用内存.物理内存和交换空间的和就是可提供的虚拟内存的总量.Linux有两种形式的交换方式,分别是交换分区,交换文件. 优点 ...

  10. Solidity遍历

    实际上,映射对于存储地址的标记值非常有用. 我们在许多合约中都看到了它们,它们通常以这种方式定义: mapping (address => uint) public users; 由于映射是公共 ...