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

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #100: Arranged probability

Project Euler #100: Arranged probability

Contest ends in
Problem
Submissions
Leaderboard
Discussions

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

If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs is as follows:

The next such arrangement, for which there is exactly 50% chance of taking two blue discs at random, is a box containing eighty-five blue discs and thirty-five red discs.

Find the first arrangement to contain discs in total where the probability of taking two blue discs is exactly .

Input Format

The first line containts an integer , the number of test cases. The next lines each contain three space-separated integers .

Constraints



Output Format

For each test case, print the number of blue discs and the number of total discs separated by a space. If there is no solution, print "No solution" instead.

Every number in the output will be less than , but it may be easier to approach this problem using bignums, depending on implementation.

Sample Input

5
1 2 2
1 2 5
1 2 100
1 4 100
3 8 1000

Sample Output

3 4
15 21
85 120
No solution
931 1520

Author

MarcusAndrews

Difficulty

Advanced

Max Score

100

Submitted By

698

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