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 #207: Integer partition equations

Project Euler #207: Integer partition equations

Problem
Submissions
Leaderboard
Discussions

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

For some positive integers , there exists an integer partition of the form ,
where , and are all positive integers and is a real number.

The first two such partitions are and .

Partitions where is also an integer are called .
For any let be the proportion of such partitions that are perfect with .
Thus .

In the following table are listed some values of







...

Find the smallest for which .

Input Format

First line of each test file contains a single integer that is the number of queries per test file. lines follow, with two integers and separated by a single space on each.

Constraints

Output Format

Print exactly lines with an answer for the corresponding query on each.

Sample Input 0

2
2 3
9 20

Sample Output 0

6
30

Explanation 0

, but , therefore, an answer for the first query is .
, which is the first value less than among all where .

Author

bayleef

Difficulty

Easy

Max Score

100

Submitted By

853

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
  • Request a Feature