快速切题 sgu115. Calendar 模拟 难度:0
115. Calendar
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
First year of new millenium is gone away. In commemoration of it write a program that finds the name of the day of the week for any date in 2001.
Input
Input is a line with two positive integer numbers N and M, where N is a day number in month M. N and M is not more than 100.
Output
Write current number of the day of the week for given date (Monday – number 1, … , Sunday – number 7) or phrase “Impossible” if such date does not exist.
Sample Input
21 10
Sample Output
7
#include <cstdio>
#include <cstring>
using namespace std;
const int date[12]={31,28, 31,30,31 ,30,31,31 ,30,31,30,31};
int main(){
int day,month,orgdat=0;
scanf("%d%d",&day,&month);month--;
if((month<0||month>=12)||day<=0||day>date[month])puts("Impossible");
else {for(int i=0;i<9;i++)orgdat+=date[i];
orgdat+=21;
orgdat=7-orgdat%7;
for(int i=0;i<month;i++){
orgdat+=date[i];
}
orgdat+=day;orgdat%=7;
printf("%d\n",orgdat==0?7:orgdat);}
return 0;
}
快速切题 sgu115. Calendar 模拟 难度:0的更多相关文章
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
- 快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 247781 Accepted: 44015 Descr ...
- LeetCode 6 ZigZag Conversion 模拟 难度:0
https://leetcode.com/problems/zigzag-conversion/ The string "PAYPALISHIRING" is written in ...
- POJ 1573 Robot Motion 模拟 难度:0
#define ONLINE_JUDGE #include<cstdio> #include <cstring> #include <algorithm> usin ...
- POJ 2632 Crashing Robots 模拟 难度:0
http://poj.org/problem?id=2632 #include<cstdio> #include <cstring> #include <algorith ...
- POJ 1068 Parencodings 模拟 难度:0
http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...
- ZOJ 3654 Letty's Math Class 模拟 难度:0
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4844 题意:给你一个只包含中括号和正整数,+,-,结果在longlong范围内 ...
- ZOJ 2477 Magic Cube 暴力,模拟 难度:0
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1477 用IDA*可能更好,但是既然时间宽裕数据简单,而且记录状态很麻烦,就直接 ...
- java web学习总结(二十一) -------------------模拟Servlet3.0使用注解的方式配置Servlet
一.Servlet的传统配置方式 在JavaWeb开发中, 每次编写一个Servlet都需要在web.xml文件中进行配置,如下所示: 1 <servlet> 2 <servlet- ...
随机推荐
- VC++ 文件和应用程序关联,默认图标不显示问题
- POJ 2975 Nim(博弈)题解
题意:已知异或和为0为必败态,异或和不为0为必胜态,问你有几种方法把开局从当前状态转为必败态. 思路:也就是说,我们要选一堆石头,然后从这堆石头拿走一些使剩下的石碓异或和为0.那么只要剩下石堆的异或和 ...
- org.apache.jasper.JasperException: /WEB-INF/view/../../../common/common1.jsp (line: 7, column: 1) Page directive must not have multiple occurrences of pageencoding
本文为博主原创,未经允许,不得转载: 先还原错误: org.apache.jasper.JasperException: /WEB-INF/view/../../../../common/common ...
- MVC ---- T4(1)
T4 模板编辑插件:tangibleT4EditorPlusModellingToolsVS2012.msi 下载地址:http://t4-editor.tangible-engineering.co ...
- R语言低级绘图函数-abline 转载
abline 函数的作用是在一张图表上添加直线, 可以是一条斜线,通过x或y轴的交点和斜率来确定位置:也可以是一条水平或者垂直的线,只需要指定与x轴或y轴交点的位置就可以了 常见用法: 1)添加直线 ...
- go 接口
1. package main import ( "fmt" ) type Phone interface { call() } type NokiaPhone struct { ...
- [ios][switf]页面跳转
参考:http://bbs.csdn.net/topics/390899712 注意用push会崩溃 用其他的正常 1.storyboard直接拖拉,使用不同种类的segue均可2.直接写代码: // ...
- shell 命令行光标跳转快捷键和history的用法
Ctrl+a: 跳到命令行首 Ctrl+e: 跳到命令行尾 Ctrl+u: 删除光标至命令行首的内容 Ctrl+k: 删除光标至命令行尾的内容 Ctrl+<- 跳到前一个单词首部 Ctrl+-& ...
- YOLO V2论文理解
概述 YOLO(You Only Look Once: Unified, Real-Time Object Detection)从v1版本进化到了v2版本,作者在darknet主页先行一步放出源代码, ...
- js 中的 堆栈
1.含义及对比 堆和栈都是运行时内存中分配的一个数据区,因此也被称为堆区和栈区: 二者存储的数据类型和处理速度不同: 堆(heap)用于复杂数据类型(引用类型)分配空间,例如数组对象.object对象 ...