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 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
随机推荐
- ruby配置镜像源
1.打开电脑的cmd窗口,输入如下命令即可查看gem镜像: gem sources l 或是直接使用 gem sources 查询结果如下: C:\Users\Administrator>gem ...
- 利用RabbitMQ、MySQL实现超大用户级别的消息在/离线收发
由于RabbitMQ中只有队列(queue)才能存储信息,所以用RabbitMQ实现超大用户级别(百万计)的消息在/离线收发需要对每一个用户创建一个永久队列. 但是RabbitMQ节点内存有限,经测试 ...
- inner join(inner可省) 与 left join 之间的区别
关于inner join 与 left join 之间的区别,以前以为自己搞懂了,今天从前端取参数的时候发现不是预想中的结果,才知道问题出在inner join 上了. 需求是从数据库查数据,在前端以 ...
- ioc解析
引述:IoC(控制反转:Inverse of Control)是Spring容器的内核,AOP.声明式事务等功能在此基础上开花结果.但是IoC这个重要的概念却比较晦涩隐讳,不容易让人望文生义,这不能不 ...
- 宁波Uber优步司机奖励政策(12月14日到12月20日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- TensorFlow:在PyCharm中配置TensorFlow
在本地配置好TensorFlow后,如何在PyCharm中配置TensorFlow呢? 只需将当前的Python编译环境配置为TensFlow安装路径中的Pyhton环境,具体操作如下: 1. 打开‘ ...
- Please ensure JDK installation is valid and compatible with the current OS
报错如下: Gradle sync failed: Could not run JVM from the selected JDK. Please ensure JDK installation is ...
- linux下免安装版本mysql5.5 配置
进入/usr/local #cd /usr/local 下载 #wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.39-linux ...
- unity3d 计时功能舒爽解决方案
上次也写了一篇计时功能的博客 今天这篇文章和上次的文章实现思路不一样,结果一样 上篇文章地址:http://www.cnblogs.com/shenggege/p/4251123.html 思路决定一 ...
- Pyhton网络爬虫实例_豆瓣电影排行榜_BeautifulSoup4方法爬取
-----------------------------------------------------------学无止境------------------------------------- ...