ICPC NAQ 2016 J - Quick Estimates

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 1G

Problem type
ICPC North America Qualifier 2016, Problem J

Let's face it… you are not that handy. When you need to make a major home repair, you often need to hire someone to help. When they come for the first visit, they make an estimate of the cost. Here they must be careful: if they overestimate the cost, it might scare you off, but if they underestimate, the work might not be worth their time.

Because the worker is so careful, it can take a long time for them to produce the estimate. But that's frustrating — when you ask for an estimate, you really are asking for the magnitude of the cost. Will this be $10 or $100 or $1000? That's all you really want to know on a first visit.

Please help the worker make the type of estimate you desire. Write a program that, given the worker's estimate, reports just the magnitude of the cost — the number of digits needed to represent the estimate.

Input Specification

Input begins with a line containing an integer N (1 \le N \le 100). The next N lines each contain one estimated cost, which is an integer between 0 and 10^{100}. (Some of the workers overcharge quite a bit.)

Output Specification

For each estimated cost, output the number of digits required to represent it.

Sample Input 1


Sample Output 1


Sample Input 2


Sample Output 2

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported


  • 0
    KingT  commented on Dec. 13, 2018, 9:57 p.m.

    Can someone take a look at my solution. I keep getting WA, but when I try it on another compiler with the sample input and my own test cases it works. Thanks in advance.

    • 4
      magicalsoup  commented on Dec. 14, 2018, 5:18 p.m.

      let me first explain something. The input can be as large as 10^100, meaning 10 and 100 zeroes, that means there isn't a number data type(int, long ,double) in any language that can hold that. just give you a perspective, unsigned long long can hold up to about 10 ^ 20, but its about 5 times as small as the input, so try to see if there is any data type that can store this kind of input.