Problem Description

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

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

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

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

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

You have to answer t independent test cases.

Input

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

The next t lines describe test cases. Each test case is given on a separate line and consists of one integer s (1≤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.

Examples

Input

6
1
10
19
9876
12345
1000000000

Output

1
11
21
10973
13716
1111111111

题意:t 组数据,每组给出 1 个数 n,代表有 n 元钱,现在用这 n 元钱买东西,每买 10 元返现 1 元,不足 10 元不进行返现,在返现后,将剩下的钱与返现的钱相加,继续买东西,重复返现过程,问最终能买多少钱的东西

思路:照题意模拟即可

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
#define Pair pair<int,int>
LL quickPow(LL a,LL b){ LL res=1; while(b){if(b&1)res*=a; a*=a; b>>=1;} return res; }
LL multMod(LL a,LL b,LL mod){ a%=mod; b%=mod; LL res=0; while(b){if(b&1)res=(res+a)%mod; a=(a<<=1)%mod; b>>=1; } return res%mod;}
LL quickMultPowMod(LL a, LL b,LL mod){ LL res=1,k=a; while(b){if((b&1))res=multMod(res,k,mod)%mod; k=multMod(k,k,mod)%mod; b>>=1;} return res%mod;}
LL quickPowMod(LL a,LL b,LL mod){ LL res=1; while(b){if(b&1)res=(a*res)%mod; a=(a*a)%mod; b>>=1; } return res; }
LL getInv(LL a,LL mod){ return quickPowMod(a,mod-2,mod); }
LL GCD(LL x,LL y){ return !y?x:GCD(y,x%y); }
LL LCM(LL x,LL y){ return x/GCD(x,y)*y; }
const double EPS = 1E-15;
const int MOD = 1000000000+7;
const int N = 2000+5;
const int dx[] = {0,0,1,-1,1,1,-1,-1};
const int dy[] = {1,-1,0,0,1,-1,1,-1};
using namespace std;int main() {int t;scanf("%d", &t);while (t--) {LL n;scanf("%lld", &n);LL res = 0;while (n >= 0) {LL k = floor(n / 10);res += k * 10;n -= k * 10;n += k;if (n <= 9) {res += n;break;}}printf("%lld\n", res);}}

Food Buying(CF-1296B)相关推荐

  1. 【解题报告】随便练练二(CF 2300)

    [解题报告]随便练练二(CF 2300) A:Antimatter | CF383D 题意 思路 :DP 代码 B:Physical Education Lessons | CF915E 题意 思路一 ...

  2. Commentator problem(CF 2)

    题目链接 题目大意: 给定三个圆,询问是否存在点满足该点与三个圆夹角均相等,若存在多组解返回夹角最大值. 圆外一点到两圆夹角均相等: 即 sina = sinb = r1 / d1 = r2 / d2 ...

  3. D. Make a Power of Two(cf#739DIV3)

    D. Make a Power of Two 链接: link. 题意: 找出将数字转换为 2 的任意幂的最小移动次数. 题解: 先将2的xxx次幂的结果以字符串形式保存,输入字符串nnn后,因为存在 ...

  4. Web of Lies(CF 1548A)

    这是今天在打个人赛时碰见的一道题,是一道半图论半思维的题. Web of Lies 题目大意不难理解,在这里只需要注意一些细节.在加边时,只有当cnt[min]的值为1时答案才应该减1,而不是当cnt ...

  5. Magic Powder - 2 (CF 670_D)

    http://codeforces.com/problemset/problem/670/D2 The term of this problem is the same as the previous ...

  6. 【解题报告】博弈专场 (CF 2000~2200)前五题

    [解题报告]博弈专场 (CF 2000+)前五题 A:Fox and Card Game | CF388C 题意 思路 代码 B:Berzerk | CF786A 题意 思路 代码 C:Ithea P ...

  7. 软件设计师提纲+复习资料整理(上午题)

    文章目录 软件设计师考试大纲 上午题(选择题) 一.计算机组成原理 考点:CPU结构组成 考点:原码.反码.补码定点整数范围 考点:浮点数表示 考点:RISC和CISC计算机的区别 考点:奇校验与偶校 ...

  8. CF 546 div.2 D. Nastya Is Buying Lunch(思维+贪心)

    为数不多的纯靠自己想出来的DIV2 D题 题意是 给出一个排好的队列,以及m个可交换的操作(u,v) :当u在v的前面时,u和v可直接交换位置 问最后一个人(编号Pn)最多可以向前几个位置. 在正式解 ...

  9. c性能大容量cket_5千左右预算,既轻薄(高颜值)又高性能的笔记本推荐(畅玩LOL、CF、DNF、流放之路、梦幻西游)...

    在目前笔记本制造技术中,轻薄和性能二者不可兼得,轻薄的本性能不高,高性能的太厚重, 这里推荐一些既轻薄,外观好看,同时又高性能的轻薄本. 很多轻薄本多为低压U+集成显卡,性能太弱,都不适合玩大型3D网 ...

  10. 基于矩阵分解的CF算法实现(一):(Funk SVD)LFM

    基于矩阵分解的CF算法实现(一):LFM LFM也就是前面提到的Funk SVD矩阵分解 LFM原理解析 LFM(latent factor model)隐语义模型核心思想是通过隐含特征联系用户和物品 ...

最新文章

  1. 画图手册 | ImageGP:今天你“plot”了吗?
  2. 整了个程序员专用的红包封面,喜欢的来领咯!
  3. 影院平台搭建 - (2)FLV发布系统的简单搭建
  4. SDN学习之旅-RYU笔记(1)
  5. wall poj 1113
  6. ACM成长之路(干货) 我爱ACM,与君共勉
  7. php网站服务器500,php服务器错误500
  8. 移动信号突然变成无服务器,为什么移动4G信号突然变成H、E、G就无法上网, 背后的真实原因?...
  9. java中复制图片_如何在Java中实现复制图片
  10. 记载abp中Dbcontext的疑问
  11. [原]部署kubernetes dashboard(二)
  12. 【算法基础】动态规划的理解
  13. jQuery实现textarea高度根据内容自适应
  14. (转)移动互联加速金融科技的渗透 中国将成为全球最大智能投顾市场
  15. cvDilate() 图像膨胀
  16. 视频教程-CCNA趣味实战语音视频课程--企业VoIP组网实验-思科认证
  17. 用三元组存储稀疏矩阵,实现其快速转置及矩阵相乘
  18. 【网络工程】什么是7类网线7类线与超6类线的区别以及它的应用场景
  19. 51单片机电子制作DIY-----交通灯控制器
  20. ubuntu 串口调试助手

热门文章

  1. 设置笔记笔触摸区(Vista)
  2. JavaEE实战班第十五天
  3. 数据中台:不是产品,不是技术,到底是什么?(附完整PPT下载)
  4. 又发现一款牛逼的 API 敏捷开发工具
  5. 别再用Else语句写代码了!
  6. 漫画:下辈子你还当程序员么?
  7. Tomcat启动报Error listenerStart错误
  8. JEECG移动方案 - 应用系统转换移动应用的中间件实现方案
  9. 总结一些生物成像的 开源图像与插件网站
  10. HTML语法初探(一)