Sicily 1620. SCVs and minerals 星际争霸简单策略

1620. SCVs and minerals

Constraints

Time Limit: 1 secs, Memory Limit: 64 MB

Description

星际争霸

When you are playing the game call “StarCraft”, if you choose “Terran”, you will have some SCVs, some minerals, and a command center. The SCVs can collect minerals outside and put them into the command center, and you can let the command center produce SCV by minerals. You want to win the game, so you must use the SCVs to collect more minerals.

Initially you have N SCVs and M minerals. Every SCV can get C minerals in one second, and the command center can produce SCVs immediately by P minerals. You want to maximize the minerals you have after S seconds. Please calculate it.

Input

The first line of the input is a positive integer T (1<=T<=50). T is the number of test cases followed. Each test case contains 5 integers, N, M, C, P, S. (1<=N<=10, 0<=M<=100, 1<=C<=10, 50<=P<=100, 1<=S<=50)

Output

For each test case, output the maximum number of minerals you have after S seconds, in one line.
Sample Input

3
10 3 10 50 2
10 0 10 60 10
4 50 8 50 50

Sample Output

203
1090
149512


(~ ̄▽ ̄)~ 简单贪心算法,解题关键在于判断是否需要建造SCVs。怎样判定?很简单,只要建造该SCVs能够在剩下的时间收回成本即可。


#include <iostream>

using namespace std;

int main()
{
    int T, N, M, C, P, S;
    cin >> T;
    while (T--)
    {
        cin >> N >> M >> C
            >> P >> S;
        do
        {
            if (M >= P && C * S >= P)
            {
                N += M / P;
                M %= P;
            }
            M += N * C;
        } while (--S);
        cout << M << endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值