#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer","inline") #pragma GCC option("arch=native","tune=native","no-zero-upper") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2") #include #define UINT unsigned int #define LL long long int #define ULL unsigned LL #define LD long double #define FI first #define SE second #define PB push_back #define PF push_front #define V vector #define PQ priority_queue #define ALL(x) x.begin(), x.end() #define SZ(x) (int)(x).size() #define FORI(i, a, b) for(int i = a; i < b ; ++i) #define FORD(i, a, b) for(int i = a; i > b ; --i) using namespace std; using pii = pair; const LL MOD = 1ll << 32; const clock_t START_T = clock(); double time_running(){ return (double)(clock() - START_T) / CLOCKS_PER_SEC; } UINT addm(UINT a, UINT b){ a += b; if (a >= MOD) return a - MOD; if (a < 0) return a + MOD; return a; } UINT mulm(UINT a, UINT b){ return (LL)a * b % MOD; } UINT exp_by_sqr(UINT a, UINT n){ if (n == 0) return 1; return (n & 1) ? a * exp_by_sqr(a, n-1) : exp_by_sqr(a*a, n >> 1); } int main(){ ifstream cin("power.in"); ofstream cout("power.out"); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); UINT a, b, c, d, n, vx = 0; cin >> a >> b >> c >> d >> n; V pa(33, a); FORI(i,1,33){ pa[i] = pa[i-1] * pa[i-1]; } FORI(i,0,n){ b = b*c + d; UINT bc = b; UINT ab = 1; int p = 0; while(bc > 0){ if (bc & 1){ ab *= pa[p]; } bc >>= 1; p++; } vx ^= ab; } cout << vx; cerr << time_running() << endl; return 0; }