CF86A.Reflection

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9  -  a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.

Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.

Your task is to find the maximum weight of the numbers in the given range [l, r] (boundaries are included).

对于每个正整数 nn,定义整数 ψ(n)\psi(n) 为:将 nn 的十进制表示中每一位数字 aa 替换为数字 (9−a)(9 - a) 后所得的整数。我们称 ψ(n)\psi(n) 为 nn 的反射数。例如,192192 的反射数为 807807。注意,若结果有前导零(如有),应将其省略。因此,99 的反射数为 00,9191 的反射数为 88。

我们定义一个数的权重为其自身与它的反射数的乘积。于是,数 1010 的权重为 10⋅89=89010 \cdot 89 = 890。

你的任务是求出给定区间 [l, r][l,\,r](含端点)内所有数的最大权重。

输入格式

Input contains two space-separated integers l and r (1 ≤ l ≤ r ≤ 109) — bounds of the range.

输入包含两个用空格分隔的整数 ll 和 rr(1 ≤ l ≤ r ≤ 1091 ≤ l ≤ r ≤ 10^9)——该区间的边界。

输出格式

Output should contain single integer number: maximum value of the product n·ψ(n), where l ≤ n ≤ r.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).

输出应为一个整数:在 $ l \leq n \leq r $ 范围内,乘积 $ n \cdot \psi(n) $ 的最大值。

请注意,在 C++ 中读写 64 位整数时,请勿使用 %lld 格式说明符。推荐使用 cout(也可使用 %I64d)。

输入输出样例

  • 输入#1

    3 7

    输出#1

    20
  • 输入#2

    1 1

    输出#2

    8
  • 输入#3

    8 10

    输出#3

    890

说明/提示

In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.

Thus, maximum value of the product is equal to 890.

在第三个样例中,数字 8 的权重为 8⋅1=88 \cdot 1 = 8,数字 9 的权重为 9⋅0=09 \cdot 0 = 0,数字 10 的权重为 890890。

因此,该乘积的最大值为 890890。

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

首页