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. QT 设计师使用样式表添加背景

    QT create中样式表可以用来设置背景图.背景颜色.字体大小格式颜色等 1.添加背景图的话需要先添加资源文件 右击项目文件选择添加新文件,再选择QT资源文件(QT resource file)然后 ...

  2. hdu1072 Nightmare---BFS

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1072 题目大意: 在n×m的地图上,0表示墙,1表示空地,2表示人,3表示目的地,4表示有定时炸弹重 ...

  3. TCP/IP学习笔记:TCP传输控制协议(一)

    1 TCP的服务 尽管TCP和UDP都使用相同的网络层(IP),TCP却向用户提供一种面向连接的,可靠地字节流服务.两个使用TCP的应用,在彼此交换数据之前必须先建立一个TCP连接,在一个TCP连接中 ...

  4. 谁说深入浅出虚拟机难?现在我让他通俗易懂(JVM)

    1:什么是JVM大家可以想想,JVM 是什么?JVM是用来干什么的?在这里我列出了三个概念,第一个是JVM,第二个是JDK,第三个是JRE.相信大家对这三个不会很陌生,相信你们都用过,但是,你们对这三 ...

  5. [LeetCode] Complex Number Multiplication 复数相乘

    Given two strings representing two complex numbers. You need to return a string representing their m ...

  6. [LeetCode] Number Complement 补数

    Given a positive integer, output its complement number. The complement strategy is to flip the bits ...

  7. C语言中关于运算符优先级别

    在一一个表达式中可能有多个不同的运算符结合起来,由于运算符的优先级别不一样,可能会形成得到的结果不同. 优先级从上到下依次递减,最上面具有最高的优先级,逗号操作符具有最低的优先级. 对于相同的优先级, ...

  8. codeforces 651C Watchmen

    Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn t ...

  9. 51nod 1686 第k大区间

    1686 第K大区间 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 定义一个区间的值为其众数出现的次数.现给出n个数,求将所有区间的值排序后,第K大的值为多少. ...

  10. linux x86内核中的分页机制

    Linux采用了通用的四级分页机制,所谓通用就是指Linux使用这种分页机制管理所有架构的分页模型,即便某些架构并不支持四级分页.对于常见的x86架构,如果系统是32位,二级分页模型就可满足系统需求: ...