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. 重置identity值

    如果数据库在SQL2008或以上,可以参考下面方法: DBCC CHECKIDENT ( table_name [, { NORESEED | { RESEED [, new_reseed_value ...

  2. hangfire的使用

    1.安装: hangfire包.StackExchange.Redis(abp下的hangfire则安装abp.hangfire) 2.配置 startup文件configuration方法添加以下代 ...

  3. 11_python_闭包迭代器

    一.函数名(第一类对象) 函数名是一个变量,但它是一个特殊的变量,与括号配合可以执行函数的变量. def func(): print("呵呵") print(func) 结果: & ...

  4. 试着用java实现DNS(一)——DatagramSocket, DatagramPacket, Message

    一般来说,自己编写DNS是没有必要的,目前开源的dns服务软件很多,功能也很强大.但是,有时候又是很有必要的,有着诸多好处.比如说,用于企业内网,简化DNS配置,可以根据企业需求添加新的功能,非常灵活 ...

  5. CuratorFramework使用

    CuratorFrameworkFramework是ZooKeeper Client更高的抽象API 自动连接管理: 1. 当ZooKeeper客户端内部出现异常, 将自动进行重连或重试, 该过程对外 ...

  6. Dapper实现一对多对象关系聚合导航属性

    领域对象:Game(游戏), Room(游戏群),两者一对多的关系,SQL语句中会用到JOIN public class Game : AggregateRoot { public string Ta ...

  7. Shell - 简明Shell入门05 - 条件语句(Case)

    示例脚本及注释 #!/bin/bash var=$1 # 将脚本的第一个参数赋值给变量var case $var in right) echo "Right!";; wrong) ...

  8. 条件变量 sync.Cond

    sync.Cond 条件变量是基于互斥锁的,它必须有互斥锁的支撑才能发挥作用. sync.Cond 条件变量用来协调想要访问共享资源的那些线程,当共享资源的状态发生变化的时候,它可以用来通知被互斥锁阻 ...

  9. Python网络练习题

    练习题 什么是C/S架构? C/S架构客户端.服务端架构,C/S端软件主要有网络游戏,QQ等 互联网协议是什么?分别介绍五层协议中每一层的功能? 互联网协议:计算机之间的通信标准 物理层:主要是基于电 ...

  10. POJ 2575

    #include<iostream> #include<set> #include<stdio.h> using namespace std; int my_abs ...