Advertisement
193030

2017. H (WA)

Apr 27th, 2020
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. double k =0;
  8. unsigned long long x,y,z;
  9. unsigned long long n;
  10.  
  11. unsigned long long solve()
  12. {
  13.  
  14.   //  x[m] = y^(m-1) * x[1] + z * (y^(m-1) - 1) / (y - 1) mod 20000
  15.      unsigned long long temp = pow(y, n-1) * x +(z*(pow(y,n-1)-1)/(y-1));
  16.     if(temp>20000)
  17.         temp = temp%20000;
  18.  
  19.     return temp;
  20. }
  21.  
  22. int main()
  23. {
  24.  
  25. int tests =0;
  26. cin >> tests;
  27. cin.ignore();
  28.  while(tests--)
  29.     {
  30.     scanf("%Ld %Ld %Ld %Ld", &x, &y, &z, &n);
  31.     unsigned long long result = solve();
  32.     cout << result;
  33.     }
  34. return 0;
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement