FEgor04

Untitled

Aug 10th, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define DEBUG
  3. #define max3(x, y, z) max(max((x), (y)), (z))
  4. #define min3(x, y, z) min(min((x), (y)), (z))
  5. #define watch(x) cout << #x << " is " << x << endl
  6. using namespace std;
  7.  
  8. #pragma GCC target ("avx2")
  9. #pragma GCC optimization ("O3")
  10. #pragma GCC optimization ("unroll-loops")
  11.  
  12. int main() {
  13.     // ios_base::sync_with_stdio(0);
  14.     // cin.tie(NULL);
  15.     // freopen("input.txt", "r", stdin);
  16.     int n, mod;
  17.     int shekel[3];
  18.     int count[3];
  19.     fill(count, count+3, 0);
  20.     cin >> n;
  21.     mod = n;
  22.     for(int i = 0; i < 3; i++) {
  23.         cin >> shekel[i];
  24.     }
  25.     for(int i = 2; i >= 0; i--) {
  26.         count[i] = mod / shekel[i];
  27.         mod -= shekel[i] * count[i];
  28.     }
  29.     if(mod != 0) {
  30.         fill(count, count+3, 0);
  31.         int kr = 0;
  32.         if(n % shekel[1] == 0) kr = 1;
  33.         count[kr] = n / shekel[kr];
  34.         n -= count[kr] * shekel[kr];
  35.     }
  36.     for(int i = 0; i < 3; i++) {
  37.         cout << count[i] << " ";
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment