#include #include #include #include #include #include #include #include #define rep(i,n) for(int i = 0; i < n; i++) #define rep1(i,n) for(int i = 1; i <= n; i++) #define co(x) cout << x <> a >> b >> n; ll x; if (n == 0)x = 0; else if (n == 1)x == 1; else { ll x_last = 1; ll x_last2 = 0; rep(i, n - 1) { x = (a * x_last + b * x_last2) % mod; x_last2 = x_last; x_last = x; } } co(x); return 0; }