After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one from the first column and the other from the second column, such that their sum is divisible by 5.

Formally, Alyona wants to count the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and  equals 0.

As usual, Alyona has some troubles and asks you to help.

Input

The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1 000 000).

Output

Print the only integer — the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and (x + y) is divisible by 5.

Example

Input
6 12
Output
14
Input
11 14
Output
31
Input
1 5
Output
1
Input
3 8
Output
5
Input
5 7
Output
7
Input
21 21
Output
88

Note

Following pairs are suitable in the first sample case:

  • for x = 1 fits y equal to 4 or 9;
  • for x = 2 fits y equal to 3 or 8;
  • for x = 3 fits y equal to 2, 7 or 12;
  • for x = 4 fits y equal to 1, 6 or 11;
  • for x = 5 fits y equal to 5 or 10;
  • for x = 6 fits y equal to 4 or 9.

Only the pair (1, 4) is suitable in the third sample case.

 #include<bits/stdc++.h>
using namespace std; int main()
{
int n,m,t,count1,count2,temp;
while(cin>>n>>m) {
long long int ans = ;
if(n > m) {
t = n;
n = m;
m = t;
}
count1 = m / ; // 求出有多少组 (1 2 3 4 5)
count2 = m % ; // 求出剩余多少个数 for(int i = ; i <= n; i++)
{
ans += count1; //每一个数在一个循环组有能够找到一个相加模5等于0的数
temp = i % ; //temp i 在 循环组的位置
if((-temp )<= count2 && count2 != ) //根据循环组的内规律进行匹配 1--4 2--3
{
ans++;
}
} cout<<ans<<endl;
} return ;
}

CF | Alyona and Numbers的更多相关文章

  1. A. Alyona and Numbers(CF ROUND 358 DIV2)

    A. Alyona and Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...

  2. CodeForces 682A Alyona and Numbers (水题)

    Alyona and Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/A Description After fi ...

  3. Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题

    A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finish ...

  4. CF 55D - Beautiful numbers(数位DP)

    题意: 如果一个数能被自己各个位的数字整除,那么它就叫 Beautiful numbers.求区间 [a,b] 中 Beautiful numbers 的个数. 分析:先分析出,2~9 的最大的最小公 ...

  5. CF | Alyona and Mex

    Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyon ...

  6. A - Alyona and Numbers

    Description After finishing eating her bun, Alyona came up with two integers n and m. She decided to ...

  7. CF D. Beautiful numbers (数位dp)

    http://codeforces.com/problemset/problem/55/D Beautiful Numbers : 这个数能整除它的全部位上非零整数.问[l,r]之间的Beautifu ...

  8. 【数位dp】CF 55D Beautiful numbers

    题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer n ...

  9. 数位DP CF 55D Beautiful numbers

    题目链接 题意:定义"beautiful number"为一个数n能整除所有数位上非0的数字 分析:即n是数位所有数字的最小公倍数的倍数.LCM(1到9)=2520.n满足是252 ...

随机推荐

  1. switchysharp设置

    在线规则列表里面插入下面的网址:https://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt

  2. Java-NIO(八):DatagramChannel

    Java NIO中的DatagramChannel是一个能收发UDP包的通道.操作步骤: 1)打开 DatagramChannel 2)接收/发送数据 同样它也支持NIO的非阻塞模式操作,例如: @T ...

  3. JAVA数据库编程、JAVA XML解析技术

    JDBC概述 JDBC是JAVA中提供的数据库编程API curd :数据库增删改 链接字符串:String url = "mysql :/localhost :3306/jdbc/&quo ...

  4. [LeetCode] Reverse Words in a String III 翻转字符串中的单词之三

    Given a string, you need to reverse the order of characters in each word within a sentence while sti ...

  5. [HNOI 2006]鬼谷子的钱袋

    Description 鬼谷子非常聪明,正因为这样,他非常繁忙,经常有各诸侯车的特派员前来向他咨询时政.有一天,他在咸阳游历的时候,朋友告诉他在咸阳最大的拍卖行(聚宝商行)将要举行一场拍卖会,其中有一 ...

  6. [SCOI2009]生日快乐

    Description windy的生日到了,为了庆祝生日,他的朋友们帮他买了一个边长分别为 X 和 Y 的矩形蛋糕.现在包括windy ,一共有 N 个人来分这块大蛋糕,要求每个人必须获得相同面积的 ...

  7. [SDOI2011]消耗战

    题目描述 在一场战争中,战场由n个岛屿和n-1个桥梁组成,保证每两个岛屿间有且仅有一条路径可达.现在,我军已经侦查到敌军的总部在编号为1的岛屿,而且他们已经没有足够多的能源维系战斗,我军胜利在望.已知 ...

  8. [HNOI2007]最小矩形覆盖

    题目描述 给定一些点的坐标,要求求能够覆盖所有点的最小面积的矩形,输出所求矩形的面积和四个顶点坐标 输入输出格式 输入格式: 第一行为一个整数n(3<=n<=50000),从第2至第n+1 ...

  9. [Educational Codeforces Round 7]F. The Sum of the k-th Powers

    FallDream dalao找的插值练习题 题目大意:给定n,k,求Σi^k (i=1~n),对1e9+7取模.(n<=10^9,k<=10^6) 思路:令f(n)=Σi^k (i=1~ ...

  10. NGUI制作可滚动的文本框(摘,如有侵权,联系删除)

    NGUI制作可滚动的文本框 1.首先创建一个UI Root 2.选择UI Root右键 Create 选择Scoll View创建. 3.Scroll view的大小是可以调节的,调节为你需要的适当大 ...