题目描述
Country Uranux wants to launch its new nuclear missile recently.
There are 3 types of missiles that Uranux has developed successful:
Name: Juno Price per unit: $120million Range: 450km
Name: Poseidon Price per unit: $600million Range: 1100km
Name: Apollo Price per unit: $3.5billion Range: 4500km
There are some targets Uranux wants to destory, If the distance between Uranux and target is in range of a type of missile, then Uranux can use one unit of this type to destory it. Uranux needs to destory all targets, but Uranux’s commander wants to make the cost minimum. Can you give a solution?
输入
Muiltple sets of input.
In one set of input, the first line contains a integer N (N <= 100), which means the count of targets Uranux need to destory. The next line contain N integers indicate the distance (0 <= x < 2^31) between each target and Uranux (Unit: km).
输出
Output the battle plan contains missile type and count(order: Juno, Poseidon, Apollo), total cost(unit: $million), if mission impossible, output “Mission impossible!”. See sample for more details.
样例输入
3100 2000 5004400 400 400 450021500 44991100015000
样例输出
Case 1:1 Juno, 1 Poseidon, 1 Apollo. Total cost: $4220million.Case 2:3 Juno, 1 Apollo. Total cost: $3860million.Case 3:2 Apollo. Total cost: $7000million.Case 4:1 Poseidon. Total cost: $600million.Case 5:Mission impossible!
提示
来源
这题真TMSB,0该输出啥不说清楚的还让人猜真的有必要?呵呵
#include<stdio.h>
int main()
{
int i,n,k=0;
while(scanf("%d",&n)!=EOF)
{ k++;
int j=0,p=0,b=0,c=0,u=0;
int a[n];
for(i=0;i<n;i++)
{ scanf("%d",&a[i]);
if(a[i]==0)continue;
else if(a[i]<=450)
{j++;continue;}
else if(a[i]<=1100)
{p++;continue;}
else if(a[i]<=4500)
{b++;continue;}
else if(a[i]>4500)
{u++;
break;}
}
if(u>0)
{printf("Case %d:\nMission impossible!\n",k);
continue;
}
else if(n==1&&a[0]==0)
{printf("Case %d:\nTotal cost: $0million.\n",k);continue;}
else if(j!=0&&p==0&&b==0&&u==0)
{c=j*120;
printf("Case %d:\n%d Juno. Total cost: $%dmillion.\n",k,j,c);continue;}
else if(j==0&&p!=0&&b==0&&u==0)
{c=p*600;
printf("Case %d:\n%d Poseidon. Total cost: $%dmillion.\n",k,p,c);continue;}
else if(j==0&&p==0&&b!=0&&u==0)
{c=b*3500;
printf("Case %d:\n%d Apollo. Total cost: $%dmillion.\n",k,b,c);continue;}
else if(j==0&&p!=0&&b!=0&&u==0)
{c=p*600+b*3500;
printf("Case %d:\n%d Poseidon, %d Apollo. Total cost: $%dmillion.\n",k,p,b,c);continue;}
else if(j!=0&&p==0&&b!=0&&u==0)
{c=j*120+b*3500;
printf("Case %d:\n%d Juno, %d Apollo. Total cost: $%dmillion.\n",k,j,b,c);continue;}
else if(j!=0&&p!=0&&b==0&&u==0)
{c=j*120+p*600;
printf("Case %d:\n%d Juno, %d Poseidon. Total cost: $%dmillion.\n",k,j,p,c);continue;}
else if(j!=0&&p!=0&&b!=0&&u==0)
{c=j*120+p*600+b*3500;
printf("Case %d:\n%d Juno, %d Poseidon, %d Apollo. Total cost: $%dmillion.\n",k,j,p,b,c);continue;}
}
}