# 长安大学第三届ACM-ICPC程序设计竞赛（同步赛）L- Big Boss

64bit IO Format: %lld

## 题目描述

Many years later, Rainbow Island is in the mercy of big boss qiami. Big boss qiami is fond of number 9 because each side of the magic cube is made up of 9 small pieces and he changes the face value of circulating currency to 90,91,92,93,9Yuan.
One day programmer Uucloud went to a shop to buy Cat food worth n Yuan. The shopkeeper NoMoreWords and Uucloud are good friends so he will give Uucloud his change. Uucloud wants to know how many bills do they need in their trade at least.
For example, if Uucloud wants to buy cat food of 8 Yuan, he will pay a 9 Yuan bill and NoMoreWords will give Uucloud 1 Yuan bill as change. Two paper money are used in this trade.

## 输入描述:

The first line contains an integer number T, the number of test cases.
Next T lines contains a number n(1 ≤ n ≤ 109)。


## 输出描述:

For each test case print the number of bills they need at least.

//牛客网的题有毒。。辛辛苦苦写了一堆结果没有了

The shopkeeper NoMoreWords andUucloud are good friends so he will give Uucloud his change.

//取一张100的，3张10块的，然后找零一张1快的就ok

//代码如下

#include<bits/stdc++.h>
using namespace std;
long long int a[10];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int n;
scanf("%lld",&n);
int bit=1;
while(bit<=4)
{
a[bit]=n%9;
n/=9;
bit++;
}
a[5]=n;
for(int i=1;i<=4;i++)
{
if(a[i]>=5)
{
a[i]=9-a[i];
a[i+1]++;
}
}
long long int sum=0;
for(int i=1;i<=5;i++)
{
sum=sum+a[i];
}
printf("%lld\n",sum);
}
return 0;
}



• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120