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

题目链接:http://codeforces.com/contest/682/problem/A

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

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 ≤ n1 ≤ 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 ≤ n1 ≤ y ≤ m and (x + y) is divisible by 5.

Examples
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 27 or 12;
  • for x = 4 fits y equal to 16 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.

题意

给你一个n和m,让用1到n中的一个数去加上1到m中的一个数,能够实现(x+y)对5求余等于0,这样的数有几组。

代码

//根据题意可知当n=a时,m可选择的方案有(m+a)/5-a/5种,for循环求出1到n的种数和。
#include <iostream>
using namespace std;
int main()
{
    int n,m,a;
    __int64 count=0;
    cin>>n>>m;
    for(a=1;n>=a;a++){
        count+=(m+a)/5-a/5;
    }
    cout<<count<<endl;
    return 0;
}



猜你喜欢

转载自blog.csdn.net/ontheway0101/article/details/51704505