Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:枚举~~~- - 附代码

Posted by sd15w2015012893 at 2017-04-11 08:28:18 on Problem 1010
In Reply To:枚举~~~- - 附代码 Posted by:caotong0 at 2010-08-01 15:05:42
> #include<stdio.h>
> #include<string.h>
> //FILE *fa;
> int s[66]={0},a,b,c[66]={0};
> int i,t,k,i1,i2,i3,i4,sum;
> long o[1000][5][5],l;
> int tie[1000][5][5];
> 	ex[1000];
> int main()
> {
> //	fa=fopen("l.in","r");
> 	while(scanf("%d",&s[1])!=EOF)
> 	{
> 		a=1;
> 		while(s[a])
> 		{
> 			a++;
> 			scanf("%d",&s[a]);
> 		}
> 		a--;
> 		b=0;
> 		scanf("%d",&c[0]);
> 		while(c[b])
> 		{
> 			b++;
> 			scanf("%d",&c[b]);
> 		}
> 		memset(o,0,sizeof(o));
> 		memset(tie,0,sizeof(tie));
> 		memset(ex,0,sizeof(ex));
> 		for(i=a;i>=0;i--)
> 			for(i1=i;i1>=0;i1--)
> 				for(i2=i1;i2>=0;i2--)
> 					for(i3=i2;i3>=0;i3--)
> 					{
> 						t=0;
> 						sum=s[i]+s[i1]+s[i2]+s[i3];
> 						if(i) t++;if(i2)t++;
> 						if(i1)t++;if(i3)t++;
> 						k=t;
> 						if(i==i1&&i)  k--;
> 						if(i1==i2&&i1)k--;
> 						if(i2==i3&&i2)k--;
> 						l=((i*100+i1)*100+i2)*100+i3;
> 						if(o[sum][k][t])
> 						{
> 							if(o[sum][k][t]/1000000==i)
> 								tie[sum][k][t]=1;
> 							else
> 							if(o[sum][k][t]/1000000<i)
> 							{
> 								tie[sum][k][t]=0;
> 								o[sum][k][t]=l;
> 							}
> 						}
> 						else
> 						if(k>0)
> 						{
> 							o[sum][k][t]=l;
> 							ex[sum]=1;
> 						}
> 					}
> 		for(i=0;i<b;i++)
> 			if(!ex[c[i]])
> 				printf("%d ---- none\n",c[i]);
> 			else
> 			for(i1=a;i1>0;i1--)
> 				for(i2=i1;i2<5;i2++)
> 					if(tie[c[i]][i1][i2])
> 					{
> 						printf("%d (%d): tie\n",c[i],i1);
> 						i1=0;i2=5;
> 					}
> 					else
> 					if(o[c[i]][i1][i2])
> 					{
> 						printf("%d (%d):",c[i],i1);
> 						t=o[c[i]][i1][i2];
> 						for(i3=4;i3>0;i3--)
> 						{
> 							k=t%100;
> 							t=t/100;
> 							if(k)
> 								printf(" %d",s[k]);
> 						}
> 						printf("\n");
> 						i1=0;i2=5;
> 					}			
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator