Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- double k =0;
- unsigned long long x,y,z;
- unsigned long long n;
- unsigned long long solve()
- {
- // x[m] = y^(m-1) * x[1] + z * (y^(m-1) - 1) / (y - 1) mod 20000
- unsigned long long temp = pow(y, n-1) * x +(z*(pow(y,n-1)-1)/(y-1));
- if(temp>20000)
- temp = temp%20000;
- return temp;
- }
- int main()
- {
- int tests =0;
- cin >> tests;
- cin.ignore();
- while(tests--)
- {
- scanf("%Ld %Ld %Ld %Ld", &x, &y, &z, &n);
- unsigned long long result = solve();
- cout << result;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement