Petr Visits ISM
All submissions for this problem are available.
Once, The CSE department of ISM Dhanbad organizes a workshop on Competitive Programming. Guess what who is the guest of honor, Petr Mitrichev himself. On that occasion he gives a nice glimpse of how he started coding and got into Google.
After he is done with his presentation, he asks the students to solve an Arithmetico-Geometric Series to check their skills. The A.G.P is as follows:
Since, the answer could be very large. So, you need to print the actual answer mod 215372682525.
Note: Submissions are only allowed in C, C++ and Java.
First line contains a single integer T denoting the number of Test Cases. Then T lines follow. Each of the next T lines contain 4 space separated integers a d n x
Output the desired result as stated in the problem statement. Result of each test case must be presented in a new line.
Should contain all the constraints on the input data that you may have. Format it like:
- 1 ≤ T ≤ 100
- 0 ≤ a ≤ 100000
- 0 ≤ d ≤ 100000
- 0 ≤ n ≤ 100000
- 0 ≤ x ≤ 100000
Input: 2 0 2 3 4 1 2 3 5 Output: 54 232
|Tags||easy-medium, modulo, petr-visits-ism, surajjumpy|
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.