A15975 | Vika and Bonuses
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A new bonus system has been introduced at Vika's favorite cosmetics store, "Golden Pear"!
The system works as follows: suppose a customer has $b$ 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 $x$ bonuses, where $x$ is the last digit of the number $b$ . As a result, the customer's account will have $b+x$ bonuses.
For example, if a customer had $24$ bonuses, he can either get a discount of $24$ or accumulate an additional $4$ bonuses, after which his account will have $28$ bonuses.
At the moment, Vika has already accumulated $s$ bonuses.
The girl knows that during the remaining time of the bonus system, she will make $k$ 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.
The system works as follows: suppose a customer has $b$ 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 $x$ bonuses, where $x$ is the last digit of the number $b$ . As a result, the customer's account will have $b+x$ bonuses.
For example, if a customer had $24$ bonuses, he can either get a discount of $24$ or accumulate an additional $4$ bonuses, after which his account will have $28$ bonuses.
At the moment, Vika has already accumulated $s$ bonuses.
The girl knows that during the remaining time of the bonus system, she will make $k$ 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.
输入格式
Each test consists of multiple test cases. The first line contains a single integer $t$ ( $1 \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 $s$ and $k$ ( $0 \le s \le 10^9$ , $1 \le k \le 10^9$ ) — the current number of bonuses in Vika's account and how many more purchases the girl will make.
The test case consists of a single line containing two integers $s$ and $k$ ( $0 \le s \le 10^9$ , $1 \le k \le 10^9$ ) — the current number of bonuses in Vika's account and how many more purchases the girl will make.
输出格式
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 $4$ .
In the second test case, Vika can get a discount of $11$ three times, and the total discount will be $33$ .
In the third example, regardless of Vika's actions, she will always get a total discount of $0$ .
In the second test case, Vika can get a discount of $11$ three times, and the total discount will be $33$ .
In the third example, regardless of Vika's actions, she will always get a total discount of $0$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted