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. 在Linux下用CANopenSocket协议模拟CAN总线通讯

    一.参考文档 https://github.com/CANopenNode/CANopenSocket //下载 CANopenSocket 的源码 http://elinux.org/Can-uti ...

  2. MFC窗口显隐

    使用SetLayeredWindowAttributes可以方便的制作透明窗体,此函数在w2k以上才支持,而且如果希望直接使用的话,可能需要下载最新的SDK.不过此函数在w2k的user32.dll里 ...

  3. Elasticsearch和MongoDB

    Elasticsearch和MongoDB分片及高可用对比 本文旨在对比Elasticsearch和MongoDB高可用和分片的实现机制. Elasticsearch ES天生就是分布式的,那她又是如 ...

  4. 24. Spring Boot 事务的使用

    转自:https://blog.csdn.net/catoop/article/details/50595702

  5. 15、python学习手册之:元组、文件及其他

    1.使用文本来存储python对象时,必须使用转换工具把对象转成字符串 2.内置函数eval可以把字符串当做可执行程序代码:eg  s = ‘[1,2,3]’    eval(s) -->[1, ...

  6. groupbox里面添加Form

    /// <summary> /// 动态加载dll /// 反射 /// </summary> private void dynamicDll() { string dllNa ...

  7. Loading half a billion rows into MySQL---转载

    Background We have a legacy system in our production environment that keeps track of when a user tak ...

  8. 芯片TPS70925

    TPS70925电源芯片 从上图中可以看出EN脚是使能脚,并且是高使能,低失能. tps70925的典型用法: 这个芯片有很多封装,我们用的是第一个:

  9. UVA 11859 - Division Game

    看题传送门 题目大意 有一个n * m的矩阵,每个元素均为2~10000之间的正整数,两个游戏者轮流操作.每次可选一行中的1个或者多个大于1的整数把它们中的每个数都变成它的某个真因子,比如12可以变成 ...

  10. Android5.0(Lollipop) BLE蓝牙4.0+浅析code(二)

    作者:Bgwan链接:https://zhuanlan.zhihu.com/p/23347612来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. Android5.0(L ...