Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <algorithm>
- #include <map>
- using namespace std;
- typedef long long ll;
- int main()
- {
- int b1, b2, b3, m;
- cin >> b1 >> b2 >> b3 >> m;
- int najmal_kusur = m;
- int k1 = -1, k2 = -1, k3= -1;
- for(int x = 0; x <= m / b1; x++) {
- for(int y = 0; y <= m / b2; y++) {
- int suma = x * b1 + y * b2;
- suma = m - suma;
- suma /= b3;
- if(x * b1 + y * b2 + suma * b3 <= m) {
- if(najmal_kusur > m - (x * b1 + y * b2 + suma * b3)) {
- najmal_kusur = m - (x * b1 + y * b2 + suma * b3);
- k1 = x;
- k2 = y;
- k3 = suma;
- }
- }
- }
- }
- cout << najmal_kusur << endl;
- cout << k1 << " " << k2 << " " << k3 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement