oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

exponentiate Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

exponentiate.html

This question consists of T test cases. Each test case consists of three integers A, B and M. For each test case, we wish to know the value of AB (mod M).

Input

The first line will contain one integer T (1 ≤ T ≤ 100,000).

Each of the next T lines will contain three integers A, B and M (1 ≤ A, B, M ≤ 1,000,000).

Output

For each of the T test cases, output a single line containing one integer, the value of AB (mod M).

Sample Input 1

4
5 2 100
5 2 24
2 10 1000
2 10 10000

Sample Output 1

25
1
24
1024

Tags

Divide and Conquer, Math

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100102s256MBAverage
2012s256MBAverage

Judge Compile Command

g++-8 ans.cpp -o exponentiate -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.