We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #112: Bouncy numbers

Project Euler #112: Bouncy numbers

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 112 from projecteuler.net

Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, .

Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, .

We shall call a positive integer that is neither increasing nor decreasing a "bouncy" number; for example, .

Clearly there cannot be any bouncy numbers below one-hundred, but just over half of the numbers below one-thousand () are bouncy. In fact, the least number for which the proportion of bouncy numbers first reaches is .

Surprisingly, bouncy numbers become more and more common and by the time we reach the proportion of bouncy numbers is equal to .

Find the least number for which the proportion of bouncy numbers is at least .

Input Format

First line contains an integer denoting the number of test cases.
Each of the following lines contain two integers and .

Constraints

Output Format

For each of test cases print one line containing a single integer - the answer to a problem.

Sample Input

2
1 2
90 100

Sample Output

538
21780

Author

Alex_2oo8

Difficulty

Advanced

Max Score

100

Submitted By

410

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy