ZJU ACM 1005

原创 2007年09月17日 15:55:00

//2007.9.17
#include <stdio.h>

int main()
{
 int ca,cb,n;
 
 while(scanf("%d %d %d",&ca,&cb,&n)!=EOF)
 {
  int nowA,nowB,leftCap; 
  nowA=0,nowB=0,leftCap=0;

  while(nowB!=n)
  {
   if(n>ca || n==cb-ca)
   {
    if(nowA==ca)
    {
     printf("empty A/n");
     nowA=0;
    }
    else if(nowB==0)
    {
     printf("fill B/n");
     nowB=cb;
    }
    else
    {
     printf("pour B A/n");
     leftCap=ca-nowA;
     if(leftCap>=nowB)
     {
      nowA+=nowB;nowB=0;
     }
     else
     {
      nowA=ca;nowB-=leftCap;
     }
    }
   }
   else if(n<=ca)
   {
    if(nowB==cb)
    {
     printf("empty B/n");
     nowA=0;
    }
    else if(nowA==0)
    {
     printf("fill A/n");
     nowA=ca;
    }
    else
    {
     printf("pour A B/n");
     leftCap=cb-nowB;
     if(leftCap>=nowA)
     {
      nowB+=nowA;nowA=0;
     }
     else
     {
      nowB=cb;nowA-=leftCap;
     }
    }
   }
  }
  printf("success/n");
  
 }
 return 0;
}
 

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

1005 Jugs-zju

也是一道DFS的题目,但是要注意保存搜过的状态,不然会死循环的!!! #include #include #include #include using namespace std; vec...

zju1005 bfs

一开始结构体开太小了。。。死都过不去。。。。后来改成100000的竟然AC了。。。太TM坑爹了。。。 #include #include #include #define size 1...

ACM ZJU 1789 Suspects

  • 2012-11-11 13:58
  • 32KB
  • 下载

acm ZJU部分题目及详解

  • 2011-10-22 17:38
  • 835KB
  • 下载

Crashing Balloon from http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3

On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The ru...

浙大ACM题目集,ZJU

  • 2011-08-30 13:42
  • 7.57MB
  • 下载

Fire Net from http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=2

Suppose that we have a square city with straight streets. A map of a city is a square board with n r...

acm ZJU分类

  • 2008-08-01 16:01
  • 15KB
  • 下载

acm zju 额度cn

  • 2009-03-24 11:54
  • 272KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)