yordanganev

Untitled

Apr 28th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #define print(var) cout << #var << " " << var << endl;
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(false);
  8. int tests;
  9. cin >> tests;
  10. unsigned long long x, y, z, n;
  11. while (tests--) {
  12. cin >> x >> y >> z >> n;
  13. print(x);
  14. print(y);
  15. print(z);
  16. print(n);
  17. n--;
  18. n%=20000;
  19. print(n);
  20. unsigned counter = 0;
  21. int lastResult = x;
  22. int result;
  23.  
  24. while(counter < n) {
  25. result = (y*lastResult + z) % 20000;
  26. lastResult = result;
  27. counter ++;
  28. print(result);
  29. }
  30.  
  31. if(n==0) {
  32. result = (y*lastResult + z) % 20000;
  33. }
  34.  
  35. cout << result << endl;
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment