简单题目,先把时间都归到整年,然后再计算。同时为了防止减法出现xx月00日的情况,需要将d先多增加1,再恢复回来。

 #include <cstdio>
#include <cstring>
#include <cstdlib> int sy, sm, sd;
int ay, am, ad; int map[][] = {
{,,,,,,,,,,,,},
{,,,,,,,,,,,,},
}; int isLeap(int n) {
if ( (n%== && n%!=) || (n% == ) )
return ;
else
return ;
} void subDate(int d) {
int i, j, k; sy = ;
d += ;
while (d > isLeap(sy)) {
d -= isLeap(sy);
--sy;
}
i = isLeap(sy)== ? :;
j = ;
while (d > map[i][j]) {
d -= map[i][j];
--j;
}
sm = j;
sd = map[i][j] - d + ;
} void addDate(int d) {
int i, j, k; ay = ;
d += ;
while (d > isLeap(ay)) {
d -= isLeap(ay);
++ay;
}
i = isLeap(ay)== ? :;
j = ;
while (d > map[i][j]) {
d -= map[i][j];
++j;
}
am = j;
ad = d;
} int main() {
int t, d; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
//freopen("data.in", "r", stdout);
#endif scanf("%d", &t);
while (t--) {
scanf("%d", &d);
subDate(d);
addDate(d);
printf("%04d/%02d/%02d %04d/%02d/%02d\n", ay,am,ad, sy,sm,sd);
} return ;
}

【HDOJ】4515 小Q系列故事——世界上最遥远的距离的更多相关文章

  1. hdu---(4515)小Q系列故事——世界上最遥远的距离(模拟题)

    小Q系列故事——世界上最遥远的距离 Time Limit: 500/200 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)T ...

  2. HDU-4515 小Q系列故事——世界上最遥远的距离

    小Q系列故事——世界上最遥远的距离 Time Limit: 500/200 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) ...

  3. hdu4515小Q系列故事——世界上最遥远的距离

    Problem Description 世界上最遥远的距离 不是生与死 而是我就站在你面前 你却不知道我爱你 世界上最遥远的距离 不是我就站在你面前你却不知道我爱你 而是明明知道彼此相爱 却不能在一起 ...

  4. hdu4505小Q系列故事——电梯里的爱情

    小Q系列故事——电梯里的爱情 Time Limit: 300/100 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tota ...

  5. HDU 4520 小Q系列故事――最佳裁判(STL)

    小Q系列故事——最佳裁判 Problem Description 过去的2012年对小Q来说是很悲催的一年,失恋了12次,每次都要郁闷1个来月. 好在小Q是个体育迷,在最痛苦的时候,他常常用观看各种体 ...

  6. 小Q系列故事——电梯里的爱情

    小Q系列故事——电梯里的爱情 Time Limit : 300/100ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total ...

  7. (比赛)C - 小Q系列故事——最佳裁判(水题)

    C - 小Q系列故事——最佳裁判 Time Limit:200MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Des ...

  8. 小Q系列故事——屌丝的逆袭

    小Q系列故事——屌丝的逆袭 Problem Description 毕业于普通本科的小Q一直自称是资深屌丝,不仅学校不知名,甚至他自己在这个普通学校也是默默无闻——直到临近毕业的时候,班里5朵金花中的 ...

  9. HDUOJ-----4510 小Q系列故事——为什么时光不能倒流

    小Q系列故事——为什么时光不能倒流 Time Limit: 300/100 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)T ...

随机推荐

  1. redis: 6379端口下set值时出现 CLUSTERDOWN The cluster is down

    1.使用./redis-trib.rb check 192.168.242.134:6379检查出现图中的错误 2.在redis安装目录的bin下执行下列命令去cluster meet 另一个端口为7 ...

  2. vSphere文档中心

    http://pubs.vmware.com/vsphere-51/index.jsp#com.vmware.vsphere.install.doc/GUID-7C9A1E23-7FCD-4295-9 ...

  3. UITextView ios7

    UITextView *textView2 = [[UITextView alloc]initWithFrame:CGRectMake(, textView1.frame.size.height + ...

  4. LOAD DATA INFILE Syntax--官方

    LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name' [REPLACE | IGNORE] INTO TABLE tbl_n ...

  5. Target runtime Apache Tomcat v6.0 is not defined. phyy Unknown Faceted Project Problem

    Description Resource Path Location TypeTarget runtime Apache Tomcat v6.0 is not defined. phyy Unknow ...

  6. yii 自动生成的内容,分页信息(Displaying 1-10 of 15 results.)如何修改或是yii cgridview template summary

    问的白一点就是 Displaying 1-10 of 15 results 如何翻译 如果搜索的话, 搜这个会出来很多内容 yii cgridview template summary 好了,其他不说 ...

  7. spring06Aop

    1.实现前置增强 必须实现接口MethodBeforeAdvice接口 创建对应的文件 public interface Animal {//主业务接口 void eat(); //目标方法 void ...

  8. uploadify在asp.net中的试用小结

    花了差不多一下午的时间,总算把uploadify插件运行起来,在此对自己遇到的问题以及过程做一个小结. 一.使用步骤 1.在官网下载最新的插件包,并将包解压. 2.新建asp.net web项目,将解 ...

  9. 用MS自带的VS构建joint语句

    在其中一个表上,右键,选择"New Query",弹出"Add Table"对话框,将待joint的两个表Add,并选择相应字段,则会自动构建joint语句,其 ...

  10. javascript 更改控件的class.

    指定 className即可, 如通过id,可这样更改: document.getElementById("myDIV").className = "calssName& ...