<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      書山有徑勤為路>>>>>>>>

      <<<<<<<<學海無涯苦作舟!

      DFS解決USACO——Mother's Milk

      Description

      Farmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B are empty while bucket C is full of milk. Sometimes, FJ pours milk from one bucket to another until the second bucket is filled or the first bucket is empty. Once begun, a pour must be completed, of course. Being thrifty, no milk may be tossed out.

      Write a program to help FJ determine what amounts of milk he can leave in bucket C when he begins with three buckets as above, pours milk among the buckets for a while, and then notes that bucket A is empty.

      Input

      A single line with the three integers A, B, and C.

      Output

      A single line with a sorted list of all the possible amounts of milk that can be in bucket C when bucket A is empty.

      Sample Input

      2 5 10

      Sample Output

      5 6 7 8 9 10
      
      
      看到了這里的Rest數組沒有,
      既然是bool類型的,又學習了。
       
       
      #include "iostream"
      #include "string.h"
      using namespace std;
      #define size 21
      bool Rest[size];
      bool flag[size][size];
      int A, B, C;
      void DFS(int a, int b, int c)
      {
      	if(flag[a][b]) return;
      	flag[a][b] = true;
      	if(a==0) Rest[c] = true;
      	//min防溢出,max防負數
      	if(a>0 && b<B)  //A向B倒, c不變
      		DFS(max(0, a+b-B), min(B, a+b), c);
      	if(a>0 && c<C)  //A向C倒,b不變
      		DFS(max(0, a+c-C), b, min(C, a+c));
      	if(b>0 && a<A)  //B向A倒,c不變
      		DFS(min(A, a+b), max(0, b+a-A), c);
      	if(b>0 && c<C)  //B向C倒,a不變
      		DFS(a, max(0, b+c-C), min(C, b+c));
      	if(c>0 && a<A)  //C向A倒,b不變
      		DFS(min(A, a+c), b, max(0, a+c-A));
      	if(c>0 && b<B)  //C向B倒,a不變
      		DFS(a, min(B, b+c), max(0, b+c-B));
      }
      int main()
      {
      	cin>>A>>B>>C;
      	memset(flag, false, sizeof(flag));
      	memset(Rest, false, sizeof(Rest));
      	DFS(0, 0, C);
      	for(int i=0; i<C; i++)
      		if(Rest[i])
      			cout<<i<<" ";
      	cout<<C<<endl;
      }

      posted on 2011-10-16 18:45  More study needed.  閱讀(759)  評論(0)    收藏  舉報

      導航

      書山有徑勤為路>>>>>>>>

      <<<<<<<<學海無涯苦作舟!

      主站蜘蛛池模板: 国产毛片基地| 18禁无遮挡啪啪无码网站| 日韩成人无码影院| 国产无遮挡吃胸膜奶免费看| 亚洲精品一区二区18禁| 内地自拍三级在线观看| 亚洲国产精品综合久久20| 日韩中文字幕一二三视频| 99久久久国产精品免费无卡顿| 一区二区三区av天堂| 玩弄放荡人妻少妇系列| 国产精品福利一区二区久久| 国产丰满老熟女重口对白| 国产女人18毛片水真多1| 亚洲国产精品一二三区| 天堂在线www天堂中文在线| 亚洲精品乱码久久久久久蜜桃图片 | 狠狠综合久久综合88亚洲爱文| 丁香婷婷色综合激情五月| 成年无码av片在线蜜芽| 成人毛片100免费观看| 日韩精品 在线一区二区| 国产午夜亚洲精品国产成人| 91亚洲人成手机在线观看| 额济纳旗| 久久波多野结衣av| 偷偷做久久久久免费网站| 精品视频在线观看免费观看| 成人亚洲一区二区三区在线| 99在线小视频| 国产精品自拍视频免费看| 亚洲熟女精品一区二区| 久久一日本道色综合久久| 人人爽人人爽人人片av东京热| 啊轻点灬大JI巴太粗太长了在线| 日本不卡一区| 国产99在线 | 免费| 丰满的熟妇岳中文字幕| 麻豆国产va免费精品高清在线| 农村肥熟女一区二区三区| 亚洲av片在线免费观看|