Absurd Prices
InterviewTime limit1sMemory limit128 MB
Given a price in cents, decide whether some integer within 5 percent (rounded to a closed interval) has strictly smaller digit-based absurdity, where absurdity is twice the digit count minus one if the last nonzero digit is 5.
- Level
Medium6 of 10
- Topics
- Math, Brute force, Implementation, Number theory
- Solved
- No attempts yet
Problem
You have surely noticed that supermarkets, shopping centres, and vendors of all kinds seem to be in love with the digit 9: it appears in product prices more often than any other digit, preferably in the least significant positions. Your favourite chocolate bar might cost 99 cents — just low enough to advertise that it costs less than 1 euro. Your new bicycle might cost 499.98 euros, which is, of course, less than 500 euros.
While such comparisons are mathematically sound, they seem to take the customer for a fool. And who wants to lug home all those annoying small coins handed back as change?
Fortunately, FIFA has not adopted this strange pricing scheme: a ticket for the final costs 900 dollars in the first category, 600 dollars in the second, and 400 dollars in the third. These prices may be considered strange only for other reasons.
We want to tell absurd prices such as 99 cents or 499.98 euros apart from normal ones. To measure the absurdity of a positive integer, do the following:
- Remove all trailing zeros — the zeros in the least significant positions. You are left with a positive integer, call it , whose last digit is non-zero.
- Let be the number of digits of .
- If , the absurdity of the number is .
- Otherwise, the absurdity of the number is .
For example, the absurdity of is , and the absurdity of is . Using this measure, we define an absurd price: a price is absurd if and only if the closed interval contains an integer whose absurdity is smaller than the absurdity of .
Given a price in cents, decide whether it is absurd!
Input
The first line contains the number of test cases. Each of the following test cases is given on one line containing a single integer . You may assume that .
Output
For each test case, print absurd if the price is absurd and not absurd otherwise, one result per line, following the format shown in the examples.