Mishka wants to buy some food in the nearby shop. Initially, he has ss burles on his card.

Mishka can perform the following operation any number of times (possibly, zero): choose some positive integer number 1≤x≤s1≤x≤s , buy food that costs exactly xx burles and obtain ⌊x10⌋⌊x10⌋ burles as a cashback (in other words, Mishka spends xx burles and obtains ⌊x10⌋⌊x10⌋ back). The operation ⌊ab⌋⌊ab⌋ means aa divided by bb rounded down.

It is guaranteed that you can always buy some food that costs xx for any possible value of xx .

Your task is to say the maximum number of burles Mishka can spend if he buys food optimally.

For example, if Mishka has s=19s=19 burles then the maximum number of burles he can spend is 2121 . Firstly, he can spend x=10x=10 burles, obtain 11 burle as a cashback. Now he has s=10s=10 burles, so can spend x=10x=10 burles, obtain 11 burle as a cashback and spend it too.

You have to answer tt independent test cases.

Input

The first line of the input contains one integer tt (1≤t≤1041≤t≤104 ) — the number of test cases.

The next tt lines describe test cases. Each test case is given on a separate line and consists of one integer ss (1≤s≤1091≤s≤109 ) — the number of burles Mishka initially has.

Output

For each test case print the answer on it — the maximum number of burles Mishka can spend if he buys food optimally.

Example
Input

 
6
1
10
19
9876
12345
1000000000
Output

 
1
11
21
10973
13716
1111111111
大意就是假设花出去x元,能返还x/10向下取整的钱数,问有ss元的话最多可以花出去多少。根据题意可以想到每次应该在返还钱数一定的情况下尽可能少的花,这样省下来的钱加上返还的钱花出去以后相比于原来有可能获得更多的返还。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
long long ans=n;
int res=n;
while(res)
{
ans+=res/;
if(res>=)res=res%+res/;//剩下的钱满十元的话尽可能少花,即模10
else res/=;//剩下的钱不满十元的话直接花掉
}
cout<<ans<<endl;
}
}

Codeforces #617 (Div. 3)B. Food Buying的更多相关文章

  1. Codeforces #617 (Div. 3) D. Fight with Monsters(贪心,排序)

    There are nn monsters standing in a row numbered from 11 to nn . The ii -th monster has hihi health ...

  2. Codeforces #617 (Div. 3) C. Yet Another Walking Robot

    There is a robot on a coordinate plane. Initially, the robot is located at the point (0,0)(0,0) . It ...

  3. Codeforces #344 Div.2

    Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...

  4. Codeforces #345 Div.1

    Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...

  5. Codeforces Beta Round #27 (Codeforces format, Div. 2)

    Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...

  6. Codeforces#441 Div.2 四小题

    Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...

  7. codeforces #592(Div.2)

    codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...

  8. codeforces #578(Div.2)

    codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...

  9. codeforces #577(Div.2)

    codeforces #577(Div.2) A  Important Exam A class of students wrote a multiple-choice test. There are ...

随机推荐

  1. Docker - CentOS 7 安装

    1. 概述 安装 docker markdown 显示有点问题 代码块里的  后面应该跟一个换行, 但是没有跟 这样会导致部分命令直接执行没有反应 2. 环境 os CentOS7 用户 root 3 ...

  2. Go_runtime包

    package main import ( "fmt" "runtime" "time" ) //写在init函数里,main函数运行之前就 ...

  3. PowerDesigner 16.5安装、激活

    PowerDesigner安装 PowerDesigner激活 PowerDesigner运行

  4. console.log 如何打印对象

    问题描述: var obj={a:1,b:2}; console.log(obj); 控制台返回的值是object. 解决方案: console.log(JSON.stringify(obj))

  5. 攻防世界 misc Exercise 刷题记录

    1.base64stego 1.zip伪加密 2. base64文件隐写,在网上找一个脚本

  6. JAVA(3)之关于运算符的优先级

    关于运算符的优先级,我做了一个小测试,区别在于平常的运算思维和计算机思维 int result=2; result =(result=result*2)*6*(result=3+result); Sy ...

  7. Go语言基础之os

    文章引用自 package os import "os" os包提供了操作系统函数的不依赖平台的接口.设计为Unix风格的,虽然错误处理是go风格的:失败的调用会返回错误值而非错误 ...

  8. Jmeter_正则表达式提取器_提取数组 & For Each 控制器

    1.举例: https://demodaojia.ecjia.com/ 提取黄色标注的这些内容 2. 3. 匹配数字:-1 表示匹配全部,0表示随机一个 4. 5.我们获取了10组数据,通过正则提取器 ...

  9. 【MySQL】索引相关

    " 目录 普通索引 唯一索引 主键索引 组合索引 正确使用索引的情况 索引的注意事项 执行计划 axplain 慢日志记录 分页性能相关方案 索引是数据库中专门用于帮助用户快速查找数据的一种 ...

  10. 【前端之BOM和DOM】

    " 目录 #. window对象介绍 #. window子对象 1. 浏览器对象 navigator 2. 屏幕对象 screen 3. 历史 history 4. 地址(URL)  loc ...