At first, I was thinking about the problem of heavy, and found that the background data seems to be no duplication of cases = =
/*id:18906421lang:c++prog:milk3*/#include <cmath> #include <cstdio> #include <vector> #include < algorithm>using namespace Std;const int maxn = 25;int Vis[maxn][maxn][maxn] = {0};vector<int>ans;int cnt = 0,aa,b B,cc;int move_to (int v,int v1,int v2) {//V1, v2 int left = V-V2; if (V1 > left) return to left; else return v1;} void Dfs (int a,int b,int c) {if (vis[a][b][c]) return; VIS[A][B][C] = 1; if (a = = 0) ans.push_back (c); int D; A-b d = move_to (bb,a,b); DFS (a-d,b + d,c); A-c D = move_to (cc,a,c); DFS (a-d,b,c + D); B-a D = move_to (aa,b,a); DFS (A + d,b-d,c); B-C D = move_to (cc,b,c); DFS (a,b-d,c + D); C-A D = move_to (aa,c,a); DFS (A + d,b,c-d); C-B d = move_to (bb,c,b); DFS (A, B + d,c-d); return;} int main () {freopen ("milk3.in", "R", stdin); Freopen ("Milk3.out", "w", stdout); scanf ("%d%d%d",&aa,&bb,&CC); DFS (0,0,CC); Sort (Ans.begin (), Ans.end ()); for (int i = 0; i < ans.size (); i++) {if (i) printf (""); printf ("%d", ans[i]); } puts (""); return 0;}
"Usaco" Mother ' s Milk (search)