B - Alyona and Numbers

题目链接:https://cn.vjudge.net/problem/CodeForces-682A

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.

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

题意:给两个数,n,m,这连个数分别从1-n,1-m,从两个数中取俩个数相加,和是5的倍数;

思路:既然是5的倍数,那,我们每次从n这个数中取数只要只要他%5的余数就行了,再加上m,(表示最多可以从m中取这么大的数),再/5就数要求的,从m中取出可以和%5组成5的倍数的个数了,

具体看代码就理解,数比较大,要用long long 才能AC,我一开始就卡在这,头疼。。。。

#include 
#include
#include
using namespace std;
int main()
{
    long long int n,m;
    scanf("%lld%lld",&n,&m);
   long long  int ans=0;
    int t;
    for(int i=1; i<=n; i++)
    {t=i%5;
 ans+=(t+m)/5;
    }
    printf("%lld\n",ans);
    return 0;
}

 

你可能感兴趣的:(VJ)