time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture:

Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap.

Input

The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday).

Output

Print single integer: the number of columns the table should have.

Examples

input

1 7

output

6

input

1 1

output

5

input

11 6

output

5

Note

The first example corresponds to the January 2017 shown on the picture in the statements.

In the second example 1-st January is Monday, so the whole month fits into 5 columns.

In the third example 1-st November is Saturday and 5 columns is enough.

【题目链接】:http://codeforces.com/contest/760/problem/A

【题解】



1,3,5,7,8,10,12是31天.其他的除了2月28天外都是30天.

模拟现在到了第几天就好;

给的是第一天的日期.

所以从第一排到最后一排模拟一下就好.



【完整代码】

#include <bits/stdc++.h>

using namespace std;

const int days[14] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int m,d;

int main()
{
cin >> m >> d;
int now = d,cnt = 1,c = 1;
while (cnt<days[m])
{
cnt++;
now++;
if (now>7)
{
now = 1;
c++;
}
}
cout << c << endl;
return 0;
}

【codeforces 760A】Petr and a calendar的更多相关文章

  1. 【Codeforces 986B】Petr and Permutations

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] n为奇数时3n和7n+1奇偶性不同 n为偶数时也是如此 然后交换任意一对数 逆序对的对数的奇偶性会发生改变一次 求出逆序对 对n讨论得出答案. ...

  2. 【Codeforces 113B】Petr#

    Codeforces 113 B 题意:有一个母串\(S\)以及两个串\(S_{begin}\)和\(S_{end}\),问\(S\)中以\(S_{begin}\)为开头并且以\(S_{end}\)为 ...

  3. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  4. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  5. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  6. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  7. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  8. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  9. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

随机推荐

  1. Unity实现发送QQ邮件功能

    闲来无聊,用Unity简单实现了一个发送邮件的功能,希望与大家互相交流互相进步,大神勿喷,测试的是QQ邮件用到的是MailMessage类和SmtpClient类首先如果发送方使用的是个人QQ邮箱账号 ...

  2. 洛谷 P2374 搬运工

    P2374 搬运工 题目背景 陈老师喜欢网购书籍,经常一次购它个百八十本,然后拿来倒卖牟取暴利.(ps:描述要看懂) 题目描述 前些天,高一的新同学来了,他便像往常一样兜售他的书,经过一番口舌,同学们 ...

  3. virtualtemplate 接口

    虚拟接口的配置.建立.与实际接口的关联 VPN在会话连接建立之后.须要创建一个虚拟接口用于和对端之间数据传输.此时,将依照用户配置,选择一个虚拟接口模板,动态地创建一个虚拟接口. 该接口将在会话结束时 ...

  4. matlab 局部特征检测与提取(问题与特征)

    物体识别:SIFT 特征: 人脸识别:LBP 特征: 行人检测:HOG 特征: 0. 常见手工设计的低级别特征 manually designed low-level features 语音:高斯混合 ...

  5. transform属性实现翻转效果

    transform:perspective(800px) rotateY(180deg);//翻转180度,透视800px; transition-delay: 0.3s;//过程时间 opacity ...

  6. 韦东山网课https://edu.csdn.net/course/play/207/1117

    接口讲解https://edu.csdn.net/course/play/207/1117

  7. 前台Ajax发送数据给后台

    前台发ajax请求给后台 前台代码 let data= [{receiveAdd:receiveAddVal, sendAdd:sendAddVal,distance:distance,goodsNa ...

  8. 洛谷 P1206 [USACO1.2]回文平方数 Palindromic Squares

    P1206 [USACO1.2]回文平方数 Palindromic Squares 题目描述 回文数是指从左向右念和从右向左念都一样的数.如12321就是一个典型的回文数. 给定一个进制B(2< ...

  9. Windows 64位下 python3.4.3 安装numpy scipy

    Numpy: 1.在开始菜单搜索cmd打开 终端 2.在终端输入python -m pip install -U pip 3.到http://www.lfd.uci.edu/~gohlke/pytho ...

  10. Java 泛型-泛型类、泛型方法、泛型接口、通配符、上下限

    泛型: 一种程序设计语言的新特性,于Java而言,在JDK 1.5开始引入.泛型就是在设计程序的时候定义一些可变部分,在具体使用的时候再给可变部分指定具体的类型.使用泛型比使用Object变量再进行强 ...