Divide and Mod

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Write a program that answers the following question Q times:

Given three integers A, B, and C, find the integer N where NA=B and NC(modA).

Constraints

1Q105

1A,B,C109

Input Specification

The first line contains Q. The following Q lines contain 3 integers A, B, and C.

Output Specification

For each question, output on a separate line N, the integer that satisfies the conditions.

Sample Input

Copy
1
6 5 11

Sample Output

Copy
35

Explanation

N=35 satisfies both conditions when A=6,B=5,C=11: 356=5, and 3511(mod6).


Comments


  • 0
    gavin_chen  commented on July 20, 2022, 8:16 p.m. edited

    what does the symbol in the equations mean I looked all around the internet and could not identify what is means other then "identical to" which doesn't explain 35 11. Please help.


    • 3
      maxcruickshanks  commented on July 22, 2022, 3:33 p.m.

      It is a modular congruence symbol.


      • 0
        gavin_chen  commented on July 26, 2022, 8:19 p.m. edited

        Oh that help a lot guess I didn't think BOTH 35 and 11 are moded (and out of all places the answer was it was khan academy (why))