#include
#include
int c[4][4],f[4][4];
bool b[4];
int ans;
void init()
{
int a,b;
scanf("%d%d",&a,&b);
c[0][1]=a;c[1][3]=a;
c[0][2]=b;c[2][3]=b;
}
bool find(int x)
{
if(x==3)return true;
for(int i=0;i<4;i++)
{
if(f[x]<c[x]&&!b)
{
b=true;
if(find(i))
{
f[x]++;f[x]--;
return true;
}
}
}
return false;
}
void process()
{
ans=0;
memset(b,false,sizeof(b));
b[0]=true;
while(find(0))
{
memset(b,false,sizeof(b));
b[0]=true;
ans++;
}
}
int main()
{
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
init();
process();
printf("%d\n",ans);
}
是网络流做a+b的
麻烦大牛们帮我翻译下
要是有Pascal的程序直接贴上来也行
|