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