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. 【PAT甲级】1102 Invert a Binary Tree (25 分)(层次遍历和中序遍历)

    题意: 输入一个正整数N(<=10),接着输入0~N-1每个结点的左右儿子结点,输出这颗二叉树的反转的层次遍历和中序遍历. AAAAAccepted code: #define HAVE_STR ...

  2. 【Python】爬虫原理

    前言 简单来说互联网是由一个个站点和网络设备组成的大网,我们通过浏览器访问站点,站点把HTML.JS.CSS代码返回给浏览器,这些代码经过浏览器解析.渲染,将丰富多彩的网页呈现我们眼前: 一.爬虫是什 ...

  3. md5模块(Python内置模块)和hashlib模块

    转自https://my.oschina.net/duhaizhang/blog/67214 MD5模块用于产生消息摘要,康用来判断文件是否相同. python的md5模块使用非常简单,包括以下几个函 ...

  4. Centos610-Nginx-TCP代理配置

    1.安装Nginx 详见<nginx>安装 2.下载nginx_tcp_proxy_module模块 下载  wget https://github.com/yaoweibin/nginx ...

  5. Yii2框架 常用函数整合

    1.使用事务添加数据: public function create() { if($this->validate()) { $trans = Yii::$app->db->begi ...

  6. 喵星之旅-狂奔的兔子-myeclipse搭建ssm

    . 可以使用试用期限内的myeclipse,也可以找到有授权的机器进行操作.搭建好的项目框架可以直接移植到免费软件eclipse使用.或者直接购买myeclipse授权. 一.创建一个java web ...

  7. AppBar 自定义顶部导航按钮 图标、颜色 以及 TabBar 定义顶部 Tab 切换

    一.Flutter AppBar 自定义顶部按钮图标.颜色 leading   在标题前面显示的一个控件,在首页通常显示应用的 logo:在其他界面通常显示为返回按钮 title  标题,通常显示为当 ...

  8. 【PAT甲级】1093 Count PAT's (25 分)

    题意: 输入一行由大写字母'P','A','T',组成的字符串,输出一共有多少个三元组"PAT"(相对顺序为PAT即可),答案对1e9+7取模. AAAAAccepted code ...

  9. CSS制作二级菜单时,二级菜单与一级菜单不对齐

    效果如图: 部分代码如图: <li><a href="#" target="_blank">关于我们</a> <ul& ...

  10. 使用JavaScript获取样式的属性值

    1 . 在js中可以使用style属性来获取样式的属性值(只能获取内联样式的属性值) 语法格式为: HTML元素.style.样式属性; 2 .   在IE浏览器中,使用currentStyle来获取 ...