您的位置:首页 > 其它

zoj1005 Jugs

2006-06-14 20:43 281 查看
Ca与Cb互质,已经保证有解,解有多种,Special Judge不一定要和Sample一致

//zoj1005 Jugs

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

#include <stdio.h>

int ca,cb,n;

void solve()

{

int a,b,bnow;

a = b = 0;

while (b != n){

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

printf ("fill A/n");

printf ("pour A B/n");

bnow = b+ca;

if (bnow == n) {

printf ("success/n");

return;

}

}

printf ("empty B/n");

printf ("pour A B/n");

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

b = a;

if (b == n) break;

}

printf ("success/n");

}

int main()

{

#ifdef ONLINE_JUDGE

#else

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

#endif

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

solve();

#ifdef ONLINE_JUDGE

#else

fclose(stdin);

#endif

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: