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. 【资源分享】半条命2速通AHK脚本

    *----------------------------------------------[下载区]----------------------------------------------* ...

  2. Linux 下使用 ffmpeg 大批量合并 ts 文件, mp4切割文件为m3u8

    见范例 ffmpeg -i "concat:file001.ts|file002.ts|file003.ts|file004.ts......n.ts" -acodec copy ...

  3. Linux shell lrzsz上传下载命令

    安装lrzsz做上传下载 工具使用secretCRT yum install -y lrzsz 1. 服务器<发送>文件,使用命令sz 2. 服务器<接收>文件,使用命令rz

  4. 解决springboot 出现异常: java.net.BindException: Address already in use: bind

    解决springboot 出现异常: java.net.BindException: Address already in use: bind 这是引文在启动springboot 的时候,没有关闭端口 ...

  5. Mac上通过docker配置PHP开发环境

    这篇文章介绍的内容是关于Mac上通过docker配置PHP开发环境,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 更多PHP相关知识请关注我的专栏PHP​zhuanlan.zhihu. ...

  6. CSS - div居中在屏幕中(水平居中 + 垂直居中)

    方法一代码 <div> <h1>404 Not Found.</h1> </div> <style> div { text-align: c ...

  7. PAT 1014 Waiting in Line (模拟)

    Suppose a bank has N windows open for service. There is a yellow line in front of the windows which ...

  8. 吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:RNN和CNN混合的鸡尾酒疗法提升网络运行效率

    from keras.layers import model = Sequential() model.add(embedding_layer) #使用一维卷积网络切割输入数据,参数5表示每各个单词作 ...

  9. ubuntu的apt

    1. apt edit-sources  #编辑apt的源列表( 或者直接写这个命令:vim /etc/apt/sources.list ) 2. apt list   #列出包含条件的包(已安装,可 ...

  10. 使用ssh 初始化git一个空java工程

    1:进入git 目录 cd /home/git/repo/ 2:创建一个java工程名 mkdir qft-payment 3:进入工程 cd  qft-payment/ 4:初始化空工程 git - ...