CF1848D.Vika and Bonuses

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

A new bonus system has been introduced at Vika's favorite cosmetics store, "Golden Pear"!

The system works as follows: suppose a customer has bb bonuses. Before paying for the purchase, the customer can choose one of two options:

  • Get a discount equal to the current number of bonuses, while the bonuses are not deducted.
  • Accumulate an additional xx bonuses, where xx is the last digit of the number bb. As a result, the customer's account will have b+xb+x bonuses.

For example, if a customer had 2424 bonuses, he can either get a discount of 2424 or accumulate an additional 44 bonuses, after which his account will have 2828 bonuses.

At the moment, Vika has already accumulated ss bonuses.

The girl knows that during the remaining time of the bonus system, she will make kk more purchases at the "Golden Pear" store network.

After familiarizing herself with the rules of the bonus system, Vika became interested in the maximum total discount she can get.

Help the girl answer this question.

维卡最喜爱的化妆品商店“金梨”推出了一套全新的积分奖励系统!

该系统规则如下:假设某顾客当前拥有 bb 个积分。在为本次购物付款前,顾客可从以下两种选项中任选其一:

  • 获得一个等于当前积分数量的折扣,但积分不扣除;
  • 额外累积 xx 个积分,其中 xx 是数字 bb 的个位数字。结果,顾客账户中的积分将变为 b+xb+x 个。

例如,若顾客当前有 2424 个积分,则他可选择获得 2424 的折扣,或额外累积 44 个积分(因 2424 的个位是 44),使账户积分变为 2828 个。

目前,维卡已累积了 ss 个积分。

这位姑娘知道,在该积分奖励系统剩余的有效期内,她还将在“金梨”连锁店进行 kk 次购物。

在了解了积分奖励系统的规则后,维卡开始好奇:她所能获得的最大总折扣是多少?

请帮助这位姑娘回答这个问题。

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt (1≤t≤1051 \le t \le 10^5) — the number of test cases. The description of the test cases follows.

The test case consists of a single line containing two integers ss and kk (0≤s≤1090 \le s \le 10^9, 1≤k≤1091 \le k \le 10^9) — the current number of bonuses in Vika's account and how many more purchases the girl will make.

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤1051 \le t \le 10^5),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例由一行组成,包含两个整数 ss 和 kk(0≤s≤1090 \le s \le 10^9,1≤k≤1091 \le k \le 10^9),分别表示维卡账户中当前的积分数量,以及该女孩还将进行的购物次数。

输出格式

For each test case, output a single integer — the maximum total discount that can be obtained through the bonus system.

对于每个测试用例,输出一个整数——通过该奖励系统所能获得的最大总折扣。

输入输出样例

  • 输入#1

    6
    1 3
    11 3
    0 179
    5 1000000000
    723252212 856168102
    728598293 145725253

    输出#1

    4
    33
    0
    9999999990
    1252047198518668448
    106175170582793129

说明/提示

In the first test case, Vika can accumulate bonuses after the first and second purchases, after which she can get a discount of 44.

In the second test case, Vika can get a discount of 1111 three times, and the total discount will be 3333.

In the third example, regardless of Vika's actions, she will always get a total discount of 00.

在第一个测试用例中,维卡可在第一次和第二次购买后累积奖金,之后她可获得 44 的折扣。

在第二个测试用例中,维卡可三次获得 1111 的折扣,总折扣额为 3333。

在第三个示例中,无论维卡采取何种行动,她获得的总折扣始终为 00。

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

首页