joj2748

 2748: Pocket Money Plan

Result TIME Limit MEMORY Limit Run Times AC Times JUDGE
3s 65536K 507 249 Standard

Jack is a plain child. When his mother gives his pocket money, he always plans how to spend within one week and more. This time, he thought of a new plan: he will spent one-tenth of his balance every day, if the money to spend this time is not an integer, it will be rounded up. Jack is not good at mathematics, so he thinks that it will be spent up after 10 days.

Last month, his mother gave Jack 100 dollars again. Jack was surprise that he was still rich for 28 days.

Jack needs your help: he would like to know how many days in this way that he will spend up all the money?

Input

The first line of the input gives the number N (N<100) of test cases. Each test case includes a positive integer A (0 < A < 100000000) in one line that identifies the number of pocket money.

Output

For each case, output the days to spend up the money in one line.

Sample Input

2
10
100

Sample Output

10
28

You can also read problem H in the PDF file below.

Plase click here to download.

Problem Source: skywind




#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main()
{
    int n;int m;
    cin>>m;
    for(int t=1;t<=m;t++)
    {
        scanf("%d",&n);
        int days=0;
        while(n>0)
        {
            if(n%10==0)
            {
                n=n-(n/10);
            }
            else
            {
                n=n-(n/10+1);
            }
            days++;
        }
        cout<<days<<endl;
    }
    return 0;
}




你可能感兴趣的:(joj2748)