#include #include using namespace std; uint32_t fastPow(uint32_t x, uint32_t p) { uint32_t prod = 1; for (int i = 29; i>=0; --i) { prod *= prod; // square if (((p >> i) & 1)) { prod *= x; // multiply } } return prod & 0xffffffffL; } int main() { #ifndef __LOCAL__ ifstream cin("power.in"); ofstream cout("power.out"); #endif // __LOCAL__ uint32_t a, b0, c, d, n; a = b0 = c = d = 4234; n = 1e7; //cin >> a >> b0 >> c >> d >> n; uint32_t b = b0, res = 0; for(uint32_t i = 1;i<=n;++i) { b = b*c + d; res ^= fastPow(a, b); } cout << res << '\n'; }