fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int x,n;
  7. cin>>x>>n;
  8. int a=0;
  9. for (int i=0;i<n;i++){
  10. a=x*(1+a);
  11. }
  12. a=a+1;
  13. // 1+x+x*x+x*x*x=1+x(1+x(1+x(1+0)))
  14. cout<<a;
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5288KB
stdin
2 3
stdout
15