Advertisement
Josif_tepe

Untitled

Aug 17th, 2024
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.    int n, k;
  7.    cin >> n >> k;
  8.    
  9.    n = 2 * (n - 1);
  10.    int wins = 2e9, losses = 2e9, draws = 2e9;
  11.    for(int x = 0; x <= n; x++) {
  12.       for(int y = 0; y <= n; y++) {
  13.          for(int z = 0; z <= n; z++) {
  14.             if(x + y + z == n and 3 * x + y == k) {
  15.                if(z < losses) {
  16.                   wins = x;
  17.                   losses = z;
  18.                   draws = y;
  19.                }
  20.             }
  21.          }
  22.       }
  23.    }
  24.    cout << wins << " " << draws << " " << losses << endl;
  25.  
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement