Calendar
Time Limit: 1000MS  Memory Limit: 30000K
Total Submissions: 9787  Accepted: 3677

Description

A calendar is a system for measuring time, from hours and minutes, to months and days, and finally to years and centuries. The terms of hour, day, month, year and century are all units of time measurements of a calender system.
According to the Gregorian calendar, which is the civil calendar in use today, years evenly divisible by 4 are leap years, with the exception of centurial years that are not evenly divisible by 400. Therefore, the years 1700, 1800, 1900 and 2100 are not leap years, but 1600, 2000, and 2400 are leap years.
Given the number of days that have elapsed since January 1, 2000 A.D, your mission is to find the date and the day of the week.
Input

The input consists of lines each containing a positive integer, which is the number of days that have elapsed since January 1, 2000 A.D. The last line contains an integer ?1, which should not be processed.
You may assume that the resulting date won’t be after the year 9999.
Output

For each test case, output one line containing the date and the day of the week in the format of "YYYY-MM-DD DayOfWeek", where "DayOfWeek" must be one of "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" and "Saturday".
Sample Input

1730
1740
1750
1751
-1
Sample Output

2004-09-26 Sunday
2004-10-06 Wednesday
2004-10-16 Saturday
2004-10-17 Sunday

#include <stdio.h>
int isRunNian(int n)
{
 if(n%400==0||(n%4==0&&n%100!=0))
 return 1;
 else
 return 0;
}//是否为闰年
int monthdate(int i,int m)
{
 int date;
 if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
 date=31;
 if(i==4||i==6||i==9||i==11)
 date=30;
 if(i==2)
 {
  if(isRunNian(m))
  date=29;
  else
  date=28;
 }
 return date;
}//这个月多少天
int main()
{
 int n;
 char week[][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
 while(scanf("%d",&n)&&n!=-1)
 {
  int i,j,k,t,m;
  i=2000;j=1;t=366;k=31;m=n;
  while(m/t>0)
  {
   i++;
   m-=t;
      if(isRunNian(i))
      t=366;
      else
      t=365;
  }//计算年份
  while(m/k>0)
  {
   j++;
   m-=k;
   k=monthdate(j,i);
  }//计算月份
  printf("%d-%02d-%02d ",i,j,m+1);
  printf("%s\n",week[(n-1)%7]);
 }
 return 0;
}

【ACM】poj_2080_Calendar_201307311043的更多相关文章

  1. 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”

    按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...

  2. 【ACM】HDU1008 Elevator 新手题前后不同的代码版本

    [前言] 很久没有纯粹的写写小代码,偶然想起要回炉再来,就去HDU随便选了个最基础的题,也不记得曾经AC过:最后吃惊的发现,思路完全不一样了,代码风格啥的也有不小的变化.希望是成长了一点点吧.后面定期 ...

  3. 【ACM】魔方十一题

    0. 前言打了两年的百度之星,都没进决赛.我最大的感受就是还是太弱,总结起来就是:人弱就要多做题,人傻就要多做题.题目还是按照分类做可能效果比较好,因此,就有了做几个系列的计划.这是系列中的第一个,解 ...

  4. 【ACM】那些年,我们挖(WA)过的最短路

    不定时更新博客,该博客仅仅是一篇关于最短路的题集,题目顺序随机. 算法思想什么的,我就随便说(复)说(制)咯: Dijkstra算法:以起始点为中心向外层层扩展,直到扩展到终点为止.有贪心的意思. 大 ...

  5. 【ACM】不要62 (数位DP)

    题目:http://acm.acmcoder.com/showproblem.php?pid=2089 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新 ...

  6. 【Acm】八皇后问题

    八皇后问题,是一个古老而著名的问题,是回溯算法的典型例题. 其解决办法和我以前发过的[算法之美—Fire Net:www.cnblogs.com/lcw/p/3159414.html]类似 题目:在8 ...

  7. 【ACM】hud1166 敌兵布阵(线段树)

    经验: cout 特别慢 如果要求速度 全部用 printf !!! 在学习线段树 内容来自:http://www.cnblogs.com/shuaiwhu/archive/2012/04/22/24 ...

  8. 【acm】杀人游戏(hdu2211)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2211 杀人游戏 Time Limit: 3000/1000 MS (Java/Others)    M ...

  9. 【ACM】How many prime numbers

    http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=2&sectionid=1&problemid=2 #inclu ...

随机推荐

  1. Ruby 各种离奇运算符

    创建: 20170717 更新: 改变分类 Rails ---> Ruby 更新: 2017/10/16 增加&., #try 参考: 传送门  ||=   a ||= b相当于 a = ...

  2. simpleOS 1.0

    做了一个so simple的OS,本不好意思多说的....不过还是说下吧. 首先,买不起开发板的我没有办完完成一件事,那就是保存任务上下文,因为这个过程实际上是将寄存器的值存放到任务堆栈中去的. 而要 ...

  3. JavaScript中变速运动的数学模型构建

    AB两地直线距离相距为S,机器人β从A点向B点行进.已知机器人β的每间隔固定时间行进一段路程,其下次行进的距离为当前距离B点路程的1/q(q为正整数),求机器人第n次行进距离的表达式an以及前n项和公 ...

  4. 解决VS2008 开发Wince应用程序项目生成速度慢的问题

    最近用VS2008开发Windows Mobile程序,使用C#..NET Compact Framework,发现项目生成速度比较慢.用VS2008打开项目后,开始一段时间生成速度还能忍受,时间一长 ...

  5. Android开发利器之ActivityTracker

    版权声明:本文为xing_star原创文章,转载请注明出处! 本文同步自http://javaexception.com/archives/113 Android开发利器之ActivityTracke ...

  6. [CodeForces522B] Photo to Remember

    某一天,n个朋友在一起聚会,他们已经很久没见了,于是他们决定拍照留念. 简单的说,拍照的时候,每个人有一个高度和宽度,第i个的高度和宽度分别是hi和wi.这些人排成一条直线,照片的最小的面积必须包含所 ...

  7. Spring Boot (5) Spring Boot配置详解

    application.properties application.properties是spring boot默认的配置文件,spring boot默认会在以下两个路径搜索并加载这个文件 src\ ...

  8. JavaScript 浏览器事件解读

    1. 事件基本概念 事件是指在文档或者浏览器中发生的一些特定交互瞬间,比如打开某一个网页,浏览器加载完成后会触发 load 事件,当鼠标悬浮于某一个元素上时会触发 hover 事件,当鼠标点击某一个元 ...

  9. bootstrap-paginator基于bootstrap的分页插件

    bootstrap-paginator基于bootstrap的分页插件 GitHub 官网地址:https://github.com/lyonlai/bootstrap-paginator 步骤 引包 ...

  10. 学习廖雪峰的Python教程之Python基础

    一.缩进 编译器或者解释器就是负责把符合语法的程序代码转换成CPU能够执行的机器码,然后执行. 以#开头的语句是注释,注释是给人看的,可以是任意内容,解释器会忽略掉注释.其他每一行都是一个语句,当语句 ...