fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N, M, K;
  6. cin >> N >> M >> K;
  7.  
  8. int x; // deklaracja na początku, widoczna w całym main
  9.  
  10. if (N % 2 <= M) {
  11. x = N; // aktywacja pod warunkiem
  12. } else {
  13. x = N - 1;
  14. }
  15.  
  16.  
  17.  
  18. for (int i = 0; i < K; i++) {
  19. N -= x;
  20. M -= x / 2;
  21. M += x;
  22. }
  23.  
  24. cout << M << endl;
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5288KB
stdin
44 20 1
stdout
42