Description

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.

Sample Input

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

题意:

输入两个数n,m。从1~n和1~m中各取一个值,使两值相加为5的倍数,求总共有多少种组合。

可从1~n依次取一个值i,并和1~m中的值相加使其和成为5的倍数。

如:6,12时有:1+4,1+9,2+3,2+8,3+2,3+7,3+12...由此我们可见,取值为i时可整除的和的数目为(i+m)/5,可当i>=5时,其本身包含的5的倍数就不能计入总数,如i=6时,和为5就不成立,故总数应减掉i/5。

附AC代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int main(){
long long n,m;//注意要用long long
while(cin>>n>>m){
long long sum=;
for(int i=;i<=n;i++){//将n从1到n循环
sum+=(m+i)/;
if(i>=)
sum-=i/;
}
cout<<sum<<endl;//输出
}
return ;
}

A - Alyona and Numbers的更多相关文章

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

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

  2. 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 ...

  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 | Alyona and Numbers

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

  5. CodeForces 682A Alyona and Numbers (水题,数学)

    题意:给定两个数 m,n,问你在从1到 n,和从 1到 m中任选两个数加起来是5的倍数,问你有多少个. 析:先计算 m 和 n中有多少个取模5是从0到4的,然后根据排列组合,相乘就得到了小于等于 m ...

  6. CodeForces 682A

    D - Alyona and Numbers Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Sub ...

  7. Codeforces Round #358 (Div. 2) A B C 水 水 dfs序+dp

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

  8. Codeforces Round #381 (Div. 2)D. Alyona and a tree(树+二分+dfs)

    D. Alyona and a tree Problem Description: Alyona has a tree with n vertices. The root of the tree is ...

  9. codeforces 381 D Alyona and a tree(倍增)(前缀数组)

    Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

随机推荐

  1. IO模式——同步(堵塞、非堵塞)、异步

    为什么IO模式非常重要?由于现代的计算机和操作系统的架构决定了CPU是稀缺资源,大家都要来一起竞争.而IO(特别是网络相关的IO)的速度往往较慢.所以怎样进行IO就有了多种模式,包含同步.异步.堵塞. ...

  2. [笔记] sed and awk

    / awk程序的典型示例是将数据转换成格式化的报表,当数据拥有某种结构时就能最好的体现awk的好处:可以使用awk脚本对数据的列重新排序,甚至可以将列变成行以及将行变成列:awk的功能将文本编辑的思想 ...

  3. gridcontrol复选框功能实现(超具体)

    博主这几天就准备离职了,以后不再做.Net开发.因此这应该是我写的最后一篇关于dev控件的博文.既然是最后一篇,那就写的具体一些.画个圆满的省略号...... 本文介绍gridcontrol怎样实现复 ...

  4. datatables参数配置详解

    //@translator codepiano //@blog codepiano //@email codepiano.li@gmail.com //尝试着翻译了一下,难免有错误的地方,欢迎发邮件告 ...

  5. win10下rose2003安装与破解(图解)

    系统刷成了win10的,因为选择的是全新安装的方式,所以开发工具又得又一次安装了,rose尽管好用.但是安装破解还是有点麻烦,这里整理一下.备用,下回就不须要去网上搜索了. 安装文件下载地址:链接: ...

  6. 基于chyh1990/caffe-compact在windows vs2013上编译caffe步骤

    1.      从https://github.com/chyh1990/caffe-compact下载caffe-compact代码: 2.      通过CMake(cmake-gui)生成vs2 ...

  7. 【BZOJ1845】[Cqoi2005] 三角形面积并 几何+扫描线

    [BZOJ1845][Cqoi2005] 三角形面积并 Description 给出n个三角形,求它们并的面积. Input 第一行为n(N < = 100), 即三角形的个数 以下n行,每行6 ...

  8. csslint

    http://csslint.net/ line column title description browserwarning 1 1 Disallow @import @import preven ...

  9. Java类加载器( 死磕 6)

    [正文]Java类加载器(  CLassLoader )死磕 6:  自定义网络类加载器 本小节目录 6.1. 自定义网络类加载器的类设计 6.2. 文件传输Server端的源码 6.3. 文件传输C ...

  10. non-blocking I/O

    https://en.wikipedia.org/wiki/New_I/O_(Java) zh.wikipedia.org/wiki/Java_NIO Java NIO API提供在java.nio套 ...