fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int f2(int r, int n, int k){
  5. if (n == 0) return r;
  6. if (r <= k) return f2(r * 2, n - 1, k);
  7. else return f2(2 * (r-k), n - 1, k);
  8.  
  9. }
  10.  
  11. int main() {
  12. int n, k, r = 1;
  13. cin >> n >> k;
  14. cout << f2(r, n, k);
  15. return 0;
  16. }
Success #stdin #stdout 0s 15232KB
stdin
5 0
stdout
32