ZOJ 3712 Hard to Play

题目:http://acm.hrbust.edu.cn/vj/index.php?c=problem-problem&id=347265

代码:

#include<stdio.h>
#include<string.h>

using namespace std;

int main()
{
    int t;
    scanf("%d",&t);

    int num[4]= {300,100,50};

    while(t--)
    {
        int a[3];
        scanf("%d%d%d",&a[0],&a[1],&a[2]);

        int ans=0;
        int x=0;
        int temp;
        for(int i=0; i<3; i++)
        {
            temp=num[i];
            for(int j=0; j<a[i]; j++)
            {
                ans=ans+temp*(x*2+1);
                x=x+1;
            }

        }
        printf("%d ",ans);
        ans=0;x=0;
        for(int i=2;i>=0;i--)
        {
            temp=num[i];

            for(int j=0;j<a[i];j++)
            {
                ans=ans+temp*(x*2+1);
                x++;
            }
        }
        printf("%d\n",ans);
    }
}


华神代码:

#include<iostream>
#include<queue>
using namespace std;
queue<int> G;
queue<int> P;
int Max()
{
    int p=0;

    int combo=0;
    while(!G.empty())
    {
        p+=G.front()*(combo*2+1);
        G.pop();
        combo++;
    }
    return p;
}
int Min()
{
    int p=0;
    int combo=0;
    while(!P.empty())
    {
        p+=P.front()*(combo*2+1);
        P.pop();
        combo++;
    }
    return p;
}
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        while(!G.empty())G.pop();
        while(!P.empty())P.pop();
        int A,B,C;
        cin>>A>>B>>C;
        int sum=A+B+C;
        int i;
        for(i=0;i<C;i++)
        {
            G.push(50);
        }
        for(i=0;i<B;i++)
        {
            G.push(100);
        }
        for(i=0;i<A;i++)
        {
            G.push(300);
        }
        for(i=0;i<A;i++) P.push(300);
        for(i=0;i<B;i++) P.push(100);
        for(i=0;i<C;i++) P.push(50);
        cout<<Min()<<" "<<Max()<<endl;
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值