| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
...代码内附In Reply To:能给出程序吗··· Posted by:0406340341 at 2007-01-22 22:30:50 #include<stdio.h>
#include<string.h>
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][i]<c[x][i]&&!b[i])
{
b[i]=true;
if(find(i))
{
f[x][i]++;f[i][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()
{
init();
process();
//if(ans!=a+b)ans=a+b;
printf("%d\n",ans);
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator