A Simple Problem
Practice
0 (0 votes)
Medium
Problem
52% Success 136 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
This problem is quite simple. Your task is to calculate the sum of a geometric progression series.
You are given 3 integers R,N and M.
You have to calculate \((R + R^2 + ... + R^N) \bmod M\) .
INPUT :
First line contains an integer T, number of testcases.
\(1 \leq T \leq 10^3\)
Only line of each test case contains R, N and M.
\(1 \leq R,N,M \leq 10^8\)
OUTPUT :
Print answer to each testcase in a new line.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
1.Tiles
Points:30
1 votes
Tags:
AlgorithmsMathematicsMediumOpenLinear Algebra
Points:30
Tags:
MediumLinear AlgebraMatrix ExponentiationAlgorithmsMathematicsOpenApproved
Points:30
Tags:
Medium
Editorial
No editorial available for this problem.