POJ 2080:Calendar
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 12546 | Accepted: 4547 |
Description
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
You may assume that the resulting date won’t be after the year 9999.
Output
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>
#include<string.h>
#include<math.h>
char week[7][10]= {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
int year[2]= {365,366};
int month[2][12]= {31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31};
int type(int m)
{
if(m%4!=0||(m%100==0&&m%400!=0))
return 0;
else return 1;
}
int main()
{
int days,dayofweek;
int i=0,j=0;
while(scanf("%d",&days)!=EOF&&days!=-1)
{
dayofweek=days%7;
for(i=2000; days>=year[type(i)]; i++)
days-=year[type(i)];
for(j=0; days>=month[type(i)][j]; j++)
days-=month[type(i)][j];
printf("%d-%02d-%02d %s\n",i,j+1,days+1,week[dayofweek]);
}
return 0;
}
POJ 2080:Calendar的更多相关文章
- POJ 2080 Calendar(很水的模拟)
刚开始一直WA,才发现原来代码中两处减去年份.月份的天数的判断条件用的是>=,虽然最后考虑n=0要退回一天的情况,但还是WA.后来改成>的条件判断,省去了考虑n=0的麻烦,AC. 此题无非 ...
- Poj Maya Calendar
http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissio ...
- poj 1079 Calendar Game(博弈论 SG)
Calendar Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- POJ 1082 Calendar Game
Adam and Eve enter this year's ACM International Collegiate Programming Contest. Last night, they pl ...
- POJ 2080
import java.util.*; public class Main { public static void main(String args[]){ Scanner cin=new Scan ...
- POJ 1082 Calendar Game(找规律博弈)
传送门 以下复制自此处:http://www.xuebuyuan.com/2028180.html 博弈论题目可以用寻找必败状态的方法解决. 第一个必败状态是2001.11.04.由此可以推出其他任何 ...
- POJ 1082 Calendar Game 原来这题有个超简单的规律
万能的discuss.只需要月份和天数同奇同偶即可,9月30和11月30例外 #include <iostream> #include <cstdio> using names ...
- A过的题目
1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...
- poj 1008:Maya Calendar(模拟题,玛雅日历转换)
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64795 Accepted: 19978 D ...
随机推荐
- java配置日志总结
log4j 搭建日志环境 简单非maven项目,只需要引入log4j.jar,在类路径下添加log4j.properties即可 简单maven项目,只需要在pom.xml引入dependency,在 ...
- <Redis> 入门一 概念安装
Redis 概念 redis是一款高性能的NOSQL系列的非关系型数据库 什么是NOSQL NoSQL(NoSQL = Not Only SQL),意即“不仅 ...
- Git 教程 -- 第一天
什么是Git? Git是一个开源的分布式版本控制系统,可以有效.高速的处理从很小到非常大的项目版本管理. 为什么使用Git? 众所周知,版本控制系统分为集中式版本控制系统(SVN.CVS等)与分布式版 ...
- [Python3网络爬虫开发实战] 7.1-Selenium的使用
Selenium是一个自动化测试工具,利用它可以驱动浏览器执行特定的动作,如点击.下拉等操作,同时还可以获取浏览器当前呈现的页面的源代码,做到可见即可爬.对于一些JavaScript动态渲染的页面来说 ...
- [Python3网络爬虫开发实战] 3.1.2-处理异常
前一节我们了解了请求的发送过程,但是在网络不好的情况下,如果出现了异常,该怎么办呢?这时如果不处理这些异常,程序很可能因报错而终止运行,所以异常处理还是十分有必要的. urllib的error模块定义 ...
- Python模块:shutil、序列化(json&pickle&shelve)、xml
shutil模块: 高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fscr,fdst [, length]) # 将文件内容拷贝到另一个文件中 import shu ...
- eclipse安装Aptana 插件,并设置使之能提示css,js,html,帮助编写代码
在Eclipse 4.2 上安装 Aptana 3.2遇到的错误 就是找不到什么文件来着,我在装maven的时候也遇到了. 烦人... (这文章是我还在用eclipse的时候,为了编写js代码的时候提 ...
- EasyUI单击行数据时动态编写editor
$.extend($.fn.treegrid.methods, { addEditor: function (jq, param) { if (param instanceof Array) { $. ...
- Linux下汇编语言学习笔记62 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- csu - 1537: Miscalculation (模拟题)
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1537 因为给出的式子是必定合法的,只要用两个栈分别保存符号和数字.算出答案后和从左至右算的答案比对 ...