본문 바로가기

USACO/Bronze

백준 11999 Milk Pails (USACO February 2016 Bronze 1번)

문제 링크: https://www.acmicpc.net/problem/11999

 

11999번: Milk Pails (Bronze)

Farmer John has received an order for exactly \(M\) units of milk (\(1 \leq M \leq 1,000\)) that he needs to fill right away. Unfortunately, his fancy milking machine has just become broken, and all he has are three milk pails of integer sizes \(X\), \(Y\)

www.acmicpc.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <bits/stdc++.h>
using namespace std;
 
int x, y, m;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    cin >> x >> y >> m;
 
    int ans = 0;
    for(int i = 0; i <= 1000; i++for(int j = 0; j <= 1000; j++) {
        if(x * i + y * j <= m)
            ans = max(ans, x * i + y * j);
    }
 
    cout << ans << '\n';
    return 0;
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter