Calendar
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 12546   Accepted: 4547

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>
#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的更多相关文章

  1. POJ 2080 Calendar(很水的模拟)

    刚开始一直WA,才发现原来代码中两处减去年份.月份的天数的判断条件用的是>=,虽然最后考虑n=0要退回一天的情况,但还是WA.后来改成>的条件判断,省去了考虑n=0的麻烦,AC. 此题无非 ...

  2. Poj Maya Calendar

    http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissio ...

  3. poj 1079 Calendar Game(博弈论 SG)

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  4. POJ 1082 Calendar Game

    Adam and Eve enter this year's ACM International Collegiate Programming Contest. Last night, they pl ...

  5. POJ 2080

    import java.util.*; public class Main { public static void main(String args[]){ Scanner cin=new Scan ...

  6. POJ 1082 Calendar Game(找规律博弈)

    传送门 以下复制自此处:http://www.xuebuyuan.com/2028180.html 博弈论题目可以用寻找必败状态的方法解决. 第一个必败状态是2001.11.04.由此可以推出其他任何 ...

  7. POJ 1082 Calendar Game 原来这题有个超简单的规律

    万能的discuss.只需要月份和天数同奇同偶即可,9月30和11月30例外 #include <iostream> #include <cstdio> using names ...

  8. A过的题目

    1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...

  9. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

随机推荐

  1. 关于C/C++的一些思考(1)

    C++的前世今生: C的结构化思想: Ada的模版思想: Fortran的运算符重载思想: Simula的OO思想:封装,继承,多态: C++类型描述了变量的三个特征: 该类型在内存中占用物理空间的大 ...

  2. First C program

    come from https://mooc.study.163.com/learn/1000002011?tid=2001530003#/learn/content?type=detail& ...

  3. Jmeter关联-获取token值

    1. token就是令牌,比如你授权(登录)一个程序时,他就是个依据,判断你是否已经授权该软件:也叫关联 2. cookie就是写在客户端的一个txt文件,里面包括你登录信息之类的,这样你下次在登录某 ...

  4. 动态规划之最长公共子序列(LCS)

             在字符串S中按照其先后顺序依次取出若干个字符,并讲它们排列成一个新的字符串,这个字符串就被称为原字符串的子串          有两个字符串S1和S2,求一个最长公共子串,即求字符串 ...

  5. mongodb & macOS

    mongodb & macOS https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ https://stacko ...

  6. 安装K/3 Cloud过程中发现的两个新问题。

    卸载掉K/3 Cloud然后重装时出现下面的错误提示: 可能原因: 1.安装目录下的Setup.exe会检查操作系统版本.有些操作系统可能是被串改过注册信息,所以取不到版本信息(有些是因为盗版的原因) ...

  7. CF585E:Present for Vitalik the Philatelist

    n<=500000个2<=Ai<=1e7的数,求这样选数的方案数:先从其中挑出一个gcd不为1的集合,然后再选一个不属于该集合,且与该集合内任意一个数互质的数. 好的统计题. 其实就 ...

  8. PatentTips – EMC Virtual File System

    BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention generally relates to net ...

  9. Less Time, More profit 最大权闭合子图(最大流最小割)

    The city planners plan to build N plants in the city which has M shops. Each shop needs products fro ...

  10. JSP中HTTP状态码

    以下内容引用自http://wiki.jikexueyuan.com/project/jsp/http-status-codes.html: HTTP请求格式和HTTP响应消息的格式一样,都有以下结构 ...