Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <math.h>
- using namespace std;
- int main() {
- int a,b, x0, n;
- unsigned long long k;
- cin >> a >> b >> x0 >> n >> k;
- int x_prev, ans = 0.0;
- for (int i = 0; i < k; i++)
- {
- if (i == 0)
- {
- ans = x0 * a + (b%n);
- x_prev = ans;
- }
- else
- {
- ans = ans * a + (b%n);
- }
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement