CF682A.Alyona and Numbers

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

吃完包子后,阿廖娜想到了两个整数 $ n $ 和 $ m $。她决定写下两列整数——第一列包含从 $ 1 $ 到 $ n $ 的所有整数,第二列包含从 $ 1 $ 到 $ m $ 的所有整数。现在,这位女孩想计算:从第一列中选一个整数、从第二列中选一个整数,能组成多少对整数,使得它们的和能被 $ 5 $ 整除。

形式化地说,阿廖娜希望计算满足以下条件的整数对 $ (x,,y) $ 的个数:$ 1 \le x \le n ,, 1 \le y \le m $,且 等于 $ 0 $。

和往常一样,阿廖娜遇到了一些困难,于是请你帮忙。

输入格式

The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1 000 000).

输入仅包含一行,其中有两个整数 nn 和 mm(1 ≤ n, m ≤ 1 000 0001 ≤ n, m ≤ 1 000 000)。

输出格式

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.

输出唯一的整数——满足 1≤x≤n1 \leq x \leq n、1≤y≤m1 \leq y \leq m 且 (x+y)(x + y) 能被 55 整除的整数对 (x, y)(x,\, y) 的个数。

输入输出样例

  • 输入#1

    6 12

    输出#1

    14
  • 输入#2

    11 14

    输出#2

    31
  • 输入#3

    1 5

    输出#3

    1
  • 输入#4

    3 8

    输出#4

    5
  • 输入#5

    5 7

    输出#5

    7
  • 输入#6

    21 21

    输出#6

    88

说明/提示

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.

以下数对适用于第一个样例:

  • 当 x=1x = 1 时,满足条件的 yy 为 4 或 9;
  • 当 x=2x = 2 时,满足条件的 yy 为 3 或 8;
  • 当 x=3x = 3 时,满足条件的 yy 为 2、7 或 12;
  • 当 x=4x = 4 时,满足条件的 yy 为 1、6 或 11;
  • 当 x=5x = 5 时,满足条件的 yy 为 5 或 10;
  • 当 x=6x = 6 时,满足条件的 yy 为 4 或 9。

第三个样例中,仅有数对 (1, 4)(1,\,4) 满足条件。

输入解题思路,AI测评打分。不知道怎么写?

首页