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

菜鸟求救,为何WAQ_Q

Posted by skyatmoon at 2017-01-12 21:26:02 on Problem 2976
#include<stdio.h>
int main()
{
	int n,k,i,j;
	long long int a[1001],b[1001],t=0,p[1001],q[1001],sum1=0,sum2=0,h=0;
	double answer;
	while(~scanf("%d %d",&n,&k) && n!=0 && k!=0)
	{
		answer=0;sum1=0;sum2=0;t=0;
		for(i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
			sum1+=a[i];
		
		}
			for(i=0;i<n;i++)
		{
			scanf("%lld",&b[i]);
			sum2+=b[i];
		
		}
		for(j=0;j<k;j++)
		{
			for(i=0;i<n;i++)
		{
			if(p[i]!=a[i] && q[i]!=b[i])
			if(t>a[i]-b[i])
			{
				t=a[i]-b[i];
				p[i]=a[i];
				q[i]=b[i];
				h=i;
			}
			
		}
		sum1-=p[h];
		sum2-=q[h];
	}
		answer=(double)sum1/(double)sum2;
		printf("%.f\n",100*answer);
	}	
	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