fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int A, B, x, K;
  4.  
  5. int fungsi(){
  6. if (K>0){
  7. int tend;
  8. K-=1;
  9. tend= A*fungsi()+B;
  10. if (tend<0){
  11. return -1*(A*fungsi()+B);
  12. }
  13. else {
  14. return A*fungsi()+B;
  15. }
  16. }
  17. else {
  18. return x;
  19. }
  20. }
  21.  
  22. int main(){
  23. cin >> A >> B >> x >> K;
  24. cout << fungsi();
  25. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty