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 MN 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的更多相关文章

  1. 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted:  ...

  2. 快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0

    487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 247781   Accepted: 44015 Descr ...

  3. LeetCode 6 ZigZag Conversion 模拟 难度:0

    https://leetcode.com/problems/zigzag-conversion/ The string "PAYPALISHIRING" is written in ...

  4. POJ 1573 Robot Motion 模拟 难度:0

    #define ONLINE_JUDGE #include<cstdio> #include <cstring> #include <algorithm> usin ...

  5. POJ 2632 Crashing Robots 模拟 难度:0

    http://poj.org/problem?id=2632 #include<cstdio> #include <cstring> #include <algorith ...

  6. POJ 1068 Parencodings 模拟 难度:0

    http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...

  7. ZOJ 3654 Letty's Math Class 模拟 难度:0

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4844 题意:给你一个只包含中括号和正整数,+,-,结果在longlong范围内 ...

  8. ZOJ 2477 Magic Cube 暴力,模拟 难度:0

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1477 用IDA*可能更好,但是既然时间宽裕数据简单,而且记录状态很麻烦,就直接 ...

  9. java web学习总结(二十一) -------------------模拟Servlet3.0使用注解的方式配置Servlet

    一.Servlet的传统配置方式 在JavaWeb开发中, 每次编写一个Servlet都需要在web.xml文件中进行配置,如下所示: 1 <servlet> 2 <servlet- ...

随机推荐

  1. vs下C++内存泄露检测

    本文原链接: http://www.cnblogs.com/zouzf/p/4152279.html 参考文章: http://msdn.microsoft.com/zh-cn/library/x98 ...

  2. 删除string类型字符串中指定字符串段

    1.实现背景 在插入list行时用邮件的MessageID给对应行命名. 在回复全部邮件时,收件人变为之前收件人中出去“自己”同时加入之前发件人,抄送人还是之前的抄送人,密送人不用管,直接不用带. 在 ...

  3. Linux内核分析--系统调用【转】

    本文转载自:http://www.cnblogs.com/paperfish/p/5308505.html 前言:以下笔记除了一些讲解视频中的概念记录,图示.图示中的补充文字.总结.分析.小结部分均是 ...

  4. linux下连接无线网出现nl80211: Could not configure driver mode nl80211: deinit ifname=wlan1 disabled_11b_rates=0 wlan1: Failed to initialize driver interface

    一.背景1.1 jello@jello:~$ lsb_release -aNo LSB modules are available.Distributor ID:    UbuntuDescripti ...

  5. HDU1143 (递推)题解

    Tri Tiling Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  6. 【环境搭建】CDH版Hadoop环境搭建

    1.下载组件 首先去CDH网站上下载hadoop组件 地址:http://archive.cloudera.com/cdh5/cdh/5/ 注意版本号要与其他的组件CDH版本一致 2.环境配置 设置主 ...

  7. Linux CentOS 7 下 JDK 安装与配置

    前言 简单记录一下在CentOS 7中安装配置JDK 1.7的全过程~  ( 安装别的版本或者jre一样) 下载 首先是jdk 1.7 64bit & 32bit的下载地址: jdk-7u79 ...

  8. 每个成长者,必须学会可以练习 (来自ProcessOn流程图工具作者底部)

  9. 【eclipse】删除工作空间

  10. UVa 10618 跳舞机

    https://vjudge.net/problem/UVA-10618 这道题目题意很复杂,代码也是参考了别人的,因为自己实在是写不出.d[i][a][b][s]表示分析到第i个箭头时,此时左脚处于 ...