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;
}
//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;
}
相关文章推荐
- zoj 1005 Jugs
- ZOJ Problem Set - 1005 Jugs
- zoj 1005 Jugs || poj 1606 (广搜做法~~~~)
- zoj 1005 Jugs (模拟)
- ZOJ 1005 Jugs
- ZOJ 1005 Jugs
- ZOJ Problem Set - 1005 Jugs
- ZOJ 1005 - Jugs | UVA 571 - Jugs
- ZOJ 1005 Jugs
- ZOJ 1005 Jugs
- ZOJ Problem Set - 1005 Jugs
- ZOJ 1005 Jugs (倒水问题)
- [ZOJ 1005] Jugs (dfs倒水问题)
- ZOJ 1005 Jugs
- zoj1005 Jugs
- zoj 1005 Jugs
- zoj 1005 Jugs
- ZOJ-1005-Jugs
- ZOJ 1005 Jugs
- ZOJ--1005:Jugs(dfs)