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. java设计模式—— 工厂模式

    菜鸡互啄... 工厂模式通过定义一个创建对象的接口,让其子类决定实例化哪个工厂类.因此我们要解决接口选择的问题,实现不同的计划创建不同的对象. 首先我们定义一个轿车接口 public interfac ...

  2. python 资产管理

    python 资产管理 一.Agent 方式 1.这个方法的优点:使用简单,速度快,适合服务器较多场景使用,缺点:服务器比较占资源,性能会变低. 2.使用Agent的前提条件是客户端(服务器)特别多的 ...

  3. 基于angularJS搭建的管理系统

    前言 angularJS搭建的系统,是一年前用的技术栈,有些地方比较过时,这里只是介绍实现思路 前端架构 工程目录 项目浅析 项目依赖包配置package.json { "name" ...

  4. Docker下ETCD集群搭建

    搭建集群之前首先准备两台安装了CentOS 7的主机,并在其上安装好Docker. Master 10.100.97.46 Node 10.100.97.64 ETCD集群搭建有三种方式,分别是Sta ...

  5. Struts2笔记分享(一)

    Struts2概述1.简介Struts就是在Model2的基础上实现的一个MVC框架,它只有一个中心控制器,采用XML定制的转向的URL,采用Action来处理逻辑.2.Struts2的MVC模式MV ...

  6. MVC系列 引入MVC

    1.必须的类库 system.web.Mvc system.Web.Razor system.web.webPages system.web.webpages.razor 添加方式如下图 2.MVC项 ...

  7. python打包工具distutils、setuptools分析

    在上一篇博文中总结了python中导入包,安装包一条完整的线路.其中有一个有意思的知识点,安装包的方式有很多种,模块和包管理中打包,发布,安装也是值得研究的内容. python中安装包的方式有很多种: ...

  8. [Codeforces 919F]A Game With Numbers

    Description 题库链接 两个人 Van♂ 游戏,每人手上各有 \(8\) 张牌,牌上数字均为 \([0,4]\) 之间的数.每个人在自己的回合选自己手牌中数字不为 \(0\) 的一张与对方手 ...

  9. ●BZOJ 1444 [Jsoi2009]有趣的游戏

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1444题解.1: 概率dp,矩阵乘法,快速幂. 对所有串建立AC自动机, 那么如果在trie树 ...

  10. Codeforces Round #464 F. Cutlet

    Description 题面 有\(2*n\)的时间,去煎一块肉,肉有两面,你需要在特定的时间内翻转,使得每一面都恰好煎了\(n\)分钟,你有\(k\)次翻转的机会,每一次表示为一段时间 \([L_i ...