标签:io for 代码 amp type algorithm dp return
不知为毛,过不了
我的代码:
#include<stdio.h>
int main()
{
int n,a[30],b[30],temp,i,j,s1,s2;
double c[30];
while(scanf("%d",&n)!=EOF)
{
s1=0;
s2=0;
for(i=0;i<n;i++)
{
scanf("%d%d",&a[i],&b[i]);
s1+=a[i];
c[i]=a[i]/b[i];
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(c[i]<c[j])
{
temp=c[i];
c[i]=c[j];
c[j]=temp;
temp=b[i];
b[i]=b[j];
b[j]=temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<n;i++)
{
s2+=s1*b[i];
s1-=a[i];
}
printf("%d\n",s2);
}
}
Ac的代码:
标签:io for 代码 amp type algorithm dp return
原文地址:http://www.cnblogs.com/weiyikang/p/3877304.html