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 ...
随机推荐
- copy on write
yl::string CBaseAutopProcessor::AddAuthorizedInfo(const yl::string & strOriginalUrl, const yl::s ...
- hdu4428(Coder)线段树
Coder Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- linux 负载各项查看命令
free -h top -c 查看使用情况 sar -r/s/b 查看IO状态 iostat -x 1 10 查看服务器的状态 vmstat 查看内存使用率最后的前10个进程 ps -aux |sor ...
- nginx+redis安装配置(内存型数据库)实现session的共享
注意:借鉴原文章:http://www.cnblogs.com/roy-blog/p/7196054.html 感兴趣的可以加一下481845043 java交流群,共同进步. 1 session的概 ...
- DEA中MAVEN项目有多个子目录,如何加载构建
ddts这个项目有三个子目录,每个子目录下面也都有一个 pom.xml 此时需要 右键子目录的 pom.xml,选择Add as Maven Project,在上图中cli.core两个目 ...
- 接龙游戏(codevs 1051)
1051 接龙游戏 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Description 给出了N个单词,已经按长度排好了序 ...
- SPOJ NSUBSTR (后缀自动机)
SPOJ NSUBSTR Problem : 给一个长度为n的字符串,要求分别输出长度为1~n的子串的最多出现次数. Solution :首先对字符串建立后缀自动机,在根据fail指针建立出后缀树,对 ...
- POJ 2135_Farm Tour
题意: 从出发点到目的地往返一次,道路i连接着ai号和bi号,长度为ci.同一条路只能走一次,求最小路径长度. 分析: 如果没有往返,那么就是简单的最短路问题.如果规定严格从左到右,那么就是简单的双调 ...
- CSS实现自适应不同大小屏幕的背景大图的两种方法(转自简书)
CSS实现自适应不同大小屏幕的背景大图的两种方法 一张清晰漂亮的背景图片能给网页加分不少,设计师也经常会给页面的背景使用大图,我们既不想图片因为不同分辨率图片变形,也不希望当在大屏的情况下,背景有一块 ...
- ADSL和ITV
1.ADSL和ITV两者占用的是不同的虚通道,也就是使用不同的VLAN: 2.的确上通过不同的VPI/VCI来区分ADSL和ITV在不同通道,但不会互不影响的,因为使用的还是同一条线路的宽带速度: 3 ...