1256

题目描述

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!

提示

来源

2013东软杯

这题真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;}

    }

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值