HDU 2133 What day is it
http://acm.hdu.edu.cn/showproblem.php?pid=2133
One line is one case.
There are three integers, year(0<year<10000), month(0<=month<13), day(0<=day<32).
if the date is illegal, you should output "illegal". Or, you should output what day it is.
#include <bits/stdc++.h>
using namespace std; int a[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int b[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char s[8][10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
bool IsRunNian(int year) {
if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
return true;
return false;
}
int main() {
int year, month, day;
while(~scanf("%d%d%d", &year, &month, &day)) {
if(IsRunNian(year)) {
if(day > a[month] || month == 0 || day == 0) {
printf("illegal\n");
continue;
}
} else{
if(day > b[month] || month == 0 || day == 0) {
printf("illegal\n");
continue;
}
}
int sum = 0;
for(int i = 1; i < year; i ++) {
if(IsRunNian(i))
sum += 366;
else
sum += 365;
sum %= 7;
}
for(int i = 0; i < month; i ++) {
if(IsRunNian(year))
sum += a[i];
else
sum += b[i];
sum %= 7;
} sum += day;
sum %= 7;
printf("%s\n",s[sum]);
}
return 0;
}
HDU 2133 What day is it的更多相关文章
- HDOJ(HDU) 2133 What day is it(认识下Java的Calendar类---日期类)
Problem Description Today is Saturday, 17th Nov,2007. Now, if i tell you a date, can you tell me wha ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
随机推荐
- 泛型List集合转化为DateTable
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; name ...
- 从Oracle导出数据并导入到Hive
1.配置源和目标的数据连接 源(oracle): 目标(Hive 2.1.1),需要事先将hive的驱动程序导入HHDI的lib目录中. Hive2.1.1需要的jar包如下:可根据自身情况更换had ...
- Python基本语法元素
静态语言(C/C++.Java):脚本语言(python.JavaScript.PHP) IPO(Input.Process.Output) #:python中的注释符号:''' ''':多 ...
- Django学习之模拟架构页面跳转
背景知识,需要有一定量的HTTP基础知识 在客户端游览器通过URL向服务端发送请求时,经历了两次过程.一次是URL向服务端发起请求,一次是服务端向客户端回发响应. 由图可知,客户端一共传递两个信息,一 ...
- java 用接口实现加减乘除计算器
class Test{ public static void main(String[] args) { fun i=new fun(); jiafa s1=new jiafa(); jianfa s ...
- 由OpenResty粘合的企业Web架构
前言: 2012年2月章亦春(agentzh)在Tech-Club的一次线下聚会上以<由Lua 粘合的Nginx生态环境>为主题做了演讲,分析了企业Web架构的趋势,即一个看起来完整 ...
- [原创]python写的sniffer
import socket s=socket.socket(socket.PF_PACKET,socket.SOCK_RAW,8) while 1: data=s.recv(65535) print ...
- day 2 给程序传递参数
1.如何实现变化name name = "alex" print("欢迎%s前来指导学习"%name) 欢迎alex前来指导学习 2.sys.argv impo ...
- Javascript闭包例子
闭包的概念 内层的函数可以引用存在于包围它的函数内的变量,即使外层函数的执行已经终止.可理解为,闭包就是能够读取其他函数内部变量的函数. 表现形式是:定义在函数内部的函数. function f1() ...
- Ruby 基础教程1-6
1.循环实现方法 循环语句 (while;for; loop,until) 循环方法(times,each) 2.for for 变量 in 对象 主体 ...