click below for solution

Wednesday, 2 February 2022

Divisors and Reciprocals Solution|codesheff starter 24 for div 3


Alice is teaching Bob maths via a game called N-guesser.

Alice has a positive integer N which Bob needs to guess. She gives him two pieces of information with which to do this:

  • A positive integer X, which denotes the sum of divisors of N.
  • Two positive integers A and B, which denote that the sum of reciprocals of divisors of N is A/B.

Bob either needs to guess N or tell that no such number exists.

It can be shown that if a valid N exists, it is unique.

Input Format

  • The first line of input contains a single integer T, denoting the number of test cases. The description of T test cases follows.
  • Each test case consists of a single line of input, containing three space-separated integers X,A,B.

Output Format

For each test case, output a new line containing the answer — Alice's number N, or 1 if no such number exists.

Constraints

  • 1T1000
  • 1X109
  • 1A,B109
  • gcd(A,B)=1

Sample Input 1 

2
4 4 3
4 1 1

Sample Output 1 

3
-1

Explanation

Test case 1: The divisors of 3 are 1 and 3. Their sum is 4 and the sum of their reciprocals is 4/3.

Test case 2: It can be proved that no positive integer N exists whose divisors sum to 4 and reciprocals of divisors sum to 1.

Solution:

solution link 1

https://shareus.in/?i=yScFNErxQ

if 1st link is not work then click on another link

Solution link 2

https://shrinke.me/0joa

Solution link 3

https://afly.pro/4dPM5oi

Solution link 4

https://afly.pro/X6gV2u4

How to get link tutorial video link

https://youtu.be/0TSsPHhgwb4


No comments:

Post a Comment