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 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
随机推荐
- 如何判断一个 APP页面是否是H5页面(转载)
1.无网络断开网络,显示404或则错误页面的是H5 2.页面布局a.在手机设置.开发者选项中开启显示布局边界功能:b.进入应用查看布局边界:c.原生应用可以看到各个控件的布局边界,H5只有整个页面的一 ...
- 利用 Python 插件 xlwings 读写 Excel
Python 通过 xlwings 读取 Excel 数据 去年底公司让我做设备管理,多次委婉拒绝,最终还是做了.其实我比较喜欢技术.做管理后发现现场没有停机率统计,而原始数据有,每次要自己在Exce ...
- MySQL入门第三天(上)——函数与视图
一.MySQL函数 同样的,完整的函数可以参照开源中国的手册:http://tool.oschina.net/apidocs/apidoc?api=mysql-5.1-zh 1.字符函数 CONCAT ...
- Git中分支merge和rebase的适用场景及区别
Git merge是用来合并两个分支的. git merge b # 将b分支合并到当前分支 同样 git rebase b,也是把 b分支合并到当前分支 原理 如下: 假设你现在基于远程分 ...
- 北京Uber优步司机奖励政策(1月19日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- spring-boot日志操作
SpringBoot Logback日志配置 Logback的配置介绍: 1.Logger.appender及layout Logger作为日志的记录器,把它关联到应用的对应的context上后,主要 ...
- (转) 在Windows 下安装drush
原帖地址:http://www.drupalla.com/node/2263 Drush是一个在命令行使用的php脚本库,在服务器本地通过php解释器调用执行,可以用命令行操作的形式管理Drupal站 ...
- JQuery表单验证插件
使用jQuery的validate插件实现一个简单的表单验证 <!DOCTYPE html> <html> <head> <meta charset=&quo ...
- datawindow自动换行打印,需结合该函数一起使用
1.设置 具体步骤如下: 1) 在DataWindow Painter中打开此DataWindow对象. 2) 在需设定自动折行的列上双击鼠标, 弹开此列的属性窗口. 3) 选择P ...
- memory引擎和innodb引擎速度对比
ysql> insert into innodb_test (name) select name from innodb_test; Query OK, rows affected ( min ...