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. Go_goroutine初识

    package main import ( "fmt" ) func main() { /* 一个goroutine打印数字,另外一个goroutine打印字母,观察运行结果.. ...

  2. 实体间的关系:1:1,1:N,M:N

    *实体之间的关系* 1)1对1关系: 两个实体表内,存在相同的主键字段. 1.1)设计: 如果记录的主键值等于另一个关系表内记录的主键值,则两条 记录对应,1:1对应. 例子: #表一:学生信息表 # ...

  3. bootstrap的pillbox使用

    使用bootstrap的cameo模版,搭建了一个cms系统,使用pillbox做显示的时候,出现点击×失败的问题. 分析了一下pillbox这个控件的使用方法. pillbox的样例在cameo/f ...

  4. SpringAOP学习之5种通知

    一.Spring的AOP分为以下5种类型通知 ①前置通知(Before):在连接点执行前执行该通知 ②正常返回通知(AfterReturning):在连接点正常执行完后执行该通知,若目标方法执行异常则 ...

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

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

  6. Python - 装饰器实现缓存

    from functools import wraps def cache(func): cache = {} @wraps(func) def wrap(*args): if args not in ...

  7. eclipse 切换主题Theme

    eclipse切换主题theme 1. 打开help -> eclipse marketplace,搜索theme 2. 点击右侧安装后一直继续,直到安装完成 3. 安装完成后会重启eclips ...

  8. 消息队列(五)--- RocketMQ-消息存储2

    概述 RocketMQ存储中主要用到以下知识点: mmap 文件映射 内存池 异步刷盘 consumeQueue 同时本节将介绍各个重要的类,本篇文章将介绍 mmap 文件映射的相关方法和内存池相关知 ...

  9. SQL表名,应该用表对应资源对象的复数形式还是单数形式

    原文:http://blog.csdn.net/lizeyang 问题 SQL表名,应该用表对应资源对象的复数形式还是单数形式.例如一个用户表,表名是用user还是users更合适呢?   精华回答 ...

  10. 操作系统OS - 阻塞(Blocking)非阻塞(Non-Blocking)与同步(Synchronous)异步(Asynchronous)

    参考: http://blog.jobbole.com/103290/ https://www.zhihu.com/question/19732473/answer/23434554 http://b ...