# zoj1005 Jugs

Ca与Cb互质，已经保证有解，解有多种，Special Judge不一定要和Sample一致

1. //zoj1005 Jugs

2. //Accepted 1005 C++ 00:00.01 392K

3. #include <stdio.h>

4. int ca,cb,n;

5. void solve()

6. {

7.        int a,b,bnow;

8.        a = b = 0;

9.        while (b != n){

10.               for (int i=0; i<=(cb-b)/ca; ++i){

11.                      printf ("fill A/n");

12.                      printf ("pour A B/n");

13.                      bnow = b+ca;

14.                      if (bnow == n) {

15.                             printf ("success/n");

16.                             return;

17.                      }

18.               }

19.               printf ("empty B/n");

20.               printf ("pour A B/n");

21.               a = ca-(cb-b)%ca;

22.               b = a;

23.               if (b == n) break;

24.        }

25.        printf ("success/n");

26. }

27. int main()

28. {

29. #ifdef ONLINE_JUDGE

30. #else

31.        freopen("1005.txt","r",stdin);

32. #endif

33.        while (scanf("%d %d %d",&ca,&cb,&n)!=EOF)

34.               solve();

35. #ifdef ONLINE_JUDGE

36. #else

37.        fclose(stdin);

38. #endif

39.        return 0;

40. }

#### ZOJ1005 Jugs

2008-09-21 21:45:00

#### ZOJ1005 POJ1606 Jugs 数论法

2011-07-16 17:24:44

#### UVA-10603-Fill(BFS+优先队列)

2014-09-02 22:25:50

#### ZOJ1005解题报告

2012-03-03 19:19:03

#### 【ZSTU4216 2015年12月浙理工校赛 G】【数论 gcd】Jug Hard 两个杯子倒水能否倒腾到目标值

2015-12-23 12:21:05

#### ZOJ1005

2015-03-23 11:37:15

#### zoj1005

2015-09-15 14:33:23

#### 365. Water and Jug Problem

2016-06-26 14:53:42

#### Jug Hard【ZSTUOJ--4216】

2015-12-21 20:59:35

#### Jugs问题求解C++

2014年11月01日 19KB 下载