Benny And The Broken Odometer
Practice
4.2 (23 votes)
Mathematics
Dynamic programming
Easy Medium
Approved
Recursion
Problem
75% Success 3556 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

One fine day, Benny decided to calculate the number of kilometers that she traveled by her bicycle. Therefore, she bought an odometer and installed it onto her bicycle. But the odometer was broken. It was not able to display the digit 3. This would precisely mean, that the odometer won't be able to display the numbers having one of their digits as 3.

For example, after the number \(1299\), the odometer will show \(1400\).

Benny was traveling a lot and now she wants to know the number of kilometers that she has traveled. You will be given only the number that Benny saw on the odometer. Your task is to determine the real distance.

Input format

The input consists of several test cases.
The first line contains one integer T denoting the number of test cases.
The next T lines contain a single integer N denoting the number that Benny saw on odometer.

Output format

For each test case, print the real distance in a single line.

Constraints

  • 1T\(10\)5
  • 0N < \(10\)9

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
11 votes
Tags:
ApprovedEasyMathNumber TheoryNumber theory
Points:30
3 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingImplementationMediumOpenProbabilityStatisticsTwo dimensional
Points:10
169 votes
Tags:
ImplementationBasic ProgrammingVery-EasyReadyMathematicsApproved