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. 魔方Newlife.Cube权限系统的使用及模版覆盖详解

    讲人:大石头 时间:2018-11-14 晚上20:00 地点:钉钉群(组织代码BKMV7685)QQ群:1600800 内容:魔方Newlife.Cube权限系统的使用及模版覆盖详解 准备 源码地址 ...

  2. AEAI WM v1.6.0 升级说明,开源工作管理系统

    1 升级说明 AEAI WM v1.6.0版是AEAI WM v1.5.0版工作管理系统的升级版本,本次升级的系统是基于AEAI DP 3.8.0_20170228进行打包部署的,对产品中的功能及BU ...

  3. PHP程序员职业发展路线

    重点:把LNMP搞熟练(核心是安装配置基本操作) 1.Linux: 基本命令.操作.启动.基本服务配置(包括rpm安装文件,各种服务配置等): 会写简单的shell脚本和awk/sed 脚本命令等. ...

  4. win7 docker 挂载共享目录

    在 win7 下用 docker 不像 win10 那样方便,安装包都不一样. 在 win7 下共享一个目录的方法如下: 1. 先设置 win7 到 VirtualBox 中 docker 用的那个虚 ...

  5. win10安装Ubuntu双系统

    1.软碟通做启动盘,不要用easyBCD,比较麻烦 2.windows10中取消选择"启用快速启动(推荐)" 3.压缩出空白卷 4.重启时按F12 5.在bios中将boot pr ...

  6. java 路径的问题

    在项目开发中会碰到各种各样的获取项目路径的一些问题: 1:java项目: 以获取  类路径下的mess.properties 为例来说明: 文件在项目中的位置: src/bz/beppe/demo/r ...

  7. 用开源 ASP.NET MVC 程序 Bonobo Git Server 搭建 Git 服务器(转)

    用开源 ASP.NET MVC 程序 Bonobo Git Server 搭建 Git 服务器   现在不用Git,都不好意思说自己是程序员. 当你想用Git,而源代码服务器是Windows系统时,你 ...

  8. odoo开发笔记--与微信集成

    odoo 与微信 https://github.com/JoneXiong/oejia_wx

  9. date命令使用文档.txt

    date命令的帮助信息 [root@localhost source]# date --help用法:date [选项]... [+格式] 或:date [-u|--utc|--universal] ...

  10. c++中char类型字符串拼接以及int类型转换为char类型 && 创建文件夹

    如下所示: #include <iostream> #include <windows.h> #include <cstring> using namespace ...