快速切题 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- ...
随机推荐
- Python3基础 try-指定except-as reason 捕获打开一个不存在的文件的时候,会产生OSError异常的示例
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- ADT Bundle下载和安装
下载官方adt集成包(即ADT Bundle)并安装. Android官方已经推出adt集成包,包含了eclipse.sdk和SDK Manager,只需解压出来,然后就能运行Eclipse. 官方集 ...
- Death to Binary? (模拟)题解
思路: 除去前导0,注意两个1不能相邻(11->100),注意 0 *** 或者*** 0或者0 0情况 用string的reverse()很舒服 代码: #include<cstdio& ...
- SpringJDBC源码分析记录
我们使用JdbcTemplate时,调用的query方法为: public <T> List<T> query(String sql, @Nullable Object[] a ...
- org.apache.axis2.AxisFault: java.lang.Error: Unresolved compilation problem:
原创:转载请注明出处 今天遇到以下一个异常,找了好长时间,就是不知道什么原因, 在网上搜了好多,也没搜到相关的解决方法. 1.异常展示, org.apache.axis2.AxisFault: jav ...
- undefined!=false之解 及==比较的规则
JS中有一个基本概念就是: JavaScript中undefined==null 但undefined!==null undefined与null转换成布尔值都是false 如果按照常规想法,比如下面 ...
- UVa 10905 孩子们的游戏
https://vjudge.net/problem/UVA-10905 题意: 给定n个正整数,把它们连接成一个最大的整数. 思路: 实在是没想到直接用string来排序了. #include< ...
- IIS Express 配置json minitype
IIS Express 配置json minitype 1.在命令窗口中cd到IIS Express安装目录,默认是“C:\Program Files\IIS Express”: 2.在IIS Exp ...
- python unicode
>>> a="jkjjhhjjj" >>> a_uni = a.decode('utf-8') >>> type(a_uni) ...
- python 获取格式化时间
#!/usr/bin/python # -*- coding: UTF- -*- import time localtime = time.asctime( time.localtime(time.t ...