First Date (hnoj12952)日期计算
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 |
Output |
For each test case, print the first Gregorian date after the calendar |
Sample Input |
1582-10-04 |
Sample Output |
1582-10-15 |
题意: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)日期计算的更多相关文章
- js Date 函数方法及日期计算
js Date 函数方法 var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份 ...
- java日期比较,日期计算
版权声明:本文为楼主原创文章,未经楼主允许不得转载,如要转载请注明来源. 都是常用的日期之间的比较方法,供以后参考. 热身:获取当前时间 SimpleDateFormat df = new Simpl ...
- CalendarHelper日期计算工具,各种日期的获取和计算
今天分享一个日期获取和计算的工具类,这个最初是用在项目中获取每周每月日期用的. <Attention> 之后逛帖子的时候发现了这个专门处理日期的库,java上也有,android上还为了避 ...
- php 日期 - 计算2个日期的差值
/** * 日期-计算2个日期的差值 * @return int */ public function get_difference($date, $new_date) { $date = strto ...
- 比较两个date返回日期相差天数
public static int daydiff(Date fDate, Date oDate) { Calendar aCalendar = Calendar.getInstance(); aCa ...
- Javascript扩展String.prototype实现格式金额、格式时间、字符串连接、计算长度、是否包含、日期计算等功能
<script src="Js/jquery-3.1.1.min.js"></script> <script type="text/java ...
- js如何通过末次月经日期计算预产日期
计算方式有两种 1)直接添加280天 2)添加10月8天(参数传递,可用改成9月7天等) js中引入文件 <script src="js/jquery.min.js"> ...
- Date 时间 日期 常用方法函数
转载自https://www.cnblogs.com/lcngu/p/5154834.html 一.java.util.Date对象用来表示时间,基本方法如下: Date mDate = new Da ...
- JAVA中日期转换和日期计算的方法
日期的格式有很多形式,在使用过程中经常需要转换,下面是各种类型转换的使用例子以及日期计算方法的例子. 一.不同格式日期相互转换方法 public class TestDateConvertUtil { ...
- 如何取得SharePoint Timer Job的历史成功数和失败数,并按照日期计算排列
[问题]. 如何取得SharePoint Timer Job的历史成功数和失败数,并按照日期计算排列 [分析] 管理中心只是罗列了所有job的历史和上一次是否成功,没有关于成功和失败的统计数据 [解决 ...
随机推荐
- 获取webpart方法以及连接字符串记录
在页面地址后面添加?contents=1就可以显示所有页面的webpart部件了 server=wtcsps05;database=Testing_DB;uid=sqluser;password=wt ...
- AngularJs从数据库获取数据并显示
哈哈,昨天下午和今天早上,花上一些时间,学习AngularJs,仅是粗略预览一下.很好,非常好. 由于手上有开发ASP.NET MVC环境,就在这测试下,去数据库获取数据并显示数据. 数据库表创建,添 ...
- AEAI DP V3.8.0 升级说明,开源综合应用开发平台
1 升级说明AEAI DP 3.8版本是一次常规升级,安全机制是本次开发平台的升级重点,如果开发的应用对外部用户开放,一定要注意升级!升级说明及产品介质已上传至网盘中,地址:http://pan.ba ...
- 【mock】后端不来过夜半,闲敲mock落灯花 (mockjs+Vuex+Vue实战)
mock的由来[假] 赵师秀:南宋时期的一位前端工程师 诗词背景:在一个梅雨纷纷的夜晚,正处于项目编码阶段,书童却带来消息:写后端的李秀才在几个时辰前就赶往临安度假去了,!此时手头仅有一个简单 ...
- 日期时间类:Date,Calendar,计算类:Math
日期时间类 计算机如何表示时间? 时间戳(timestamp):距离特定时间的时间间隔. 计算机时间戳是指距离历元(1970-01-01 00:00:00:000)的时间间隔(ms). 计算机中时间2 ...
- C++ 执行Windows cmd命令
#include <windows.h> #include <iostream> #include <cstdio> using namespace std; vo ...
- <转>php中heredoc与nowdoc的使用方法
http://www.361way.com/php-heredoc-nowdoc/3008.html 一.heredoc结构及用法 Heredoc 结构就象是没有使用双引号的双引号字符串,这就是说在 ...
- oracle expdp impdp 导入导出备份
数据库导入导出: 使用EXPDP和IMPDP时应该注意的事项: EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用. EXPDP和IMPDP是服务端的工具程序,他们只能在ORA ...
- xamarin 遇到的奇葩问题
未能找到路径“E:\platforms”的一部分. xamarin 安卓存档出现这样的错误 建议检查下ndk是否配置完整
- nc命令简介
nc介绍 ncat/nc 既是一个端口扫描工具,也是一款安全工具,还能是一款监测工具,甚至可以做为一个简单的 TCP 代理. 在大多数 Debian 发行版中,nc 是默认可用的,它会在安装系统的过程 ...