mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 18:52:02 +00:00
P1215 [USACO1.4]母亲的牛奶 Mother's Milk
R52413454
This commit is contained in:
parent
ae54bdd2ee
commit
24d923f814
50
Luogu/problem/P1215/P1215.cpp
Normal file
50
Luogu/problem/P1215/P1215.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
vector<int> ans;
|
||||
bool vis[25][25][25];
|
||||
int ta, tb, tc;
|
||||
|
||||
void dfs(int a, int b, int c) {
|
||||
if (vis[a][b][c]) return;
|
||||
if (a == 0) ans.push_back(c);
|
||||
vis[a][b][c] = true;
|
||||
if (c) {
|
||||
if (a < ta) {
|
||||
dfs(min(ta, a + c), b, c - (min(ta, a + c) - a));
|
||||
}
|
||||
if (b < tb) {
|
||||
dfs(a, min(b + c, tb), c - (min(tb, b + c) - b));
|
||||
}
|
||||
}
|
||||
if (b) {
|
||||
if (a < ta) {
|
||||
dfs(min(ta, a + b), b - (min(ta, a + b) - a), c);
|
||||
}
|
||||
if (c < tc) {
|
||||
dfs(a, b - (min(tc, c + b) - c), min(tc, c + b));
|
||||
}
|
||||
}
|
||||
if (a) {
|
||||
if (b < tb) {
|
||||
dfs(a - (min(tb, a + b) - b), min(tb, a + b), c);
|
||||
}
|
||||
if (c < tc) {
|
||||
dfs(a - (min(tc, a + c) - c), b, min(tc, c + a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> ta >> tb >> tc;
|
||||
clog << 1 << endl;
|
||||
dfs(0, 0, tc);
|
||||
clog << 2 << endl;
|
||||
sort(ans.begin(), ans.end());
|
||||
for (int a : ans) {
|
||||
cout << a << ' ';
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user