Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n, x;
- long long s = 0, power = 1;
- cin >> x >> n;
- for(int i = 1; i <= n; i++){
- power = power * x * x;
- if (i % 2 == 0) s+= power;
- else s-= power;
- }
- cout << s << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement