题目的意思是,每一个单位的SCV可以在一秒内收集到C个单位的矿物,而P个单位的矿物可以立即生产出一个单位的SCV,问S秒后最多可以得到多少矿物。
基本思路是,在每一个单位时间(秒)开始时,先计算下用矿物生产出SCV的话,能否在剩余的时间内收回成本,可以的话就生产尽可能多的SCV,否则就不生产。结果显而易见。
Run Time: 0sec
Run Memory: 312KB
Code length: 400Bytes
SubmitTime: 2012-01-26 21:41:50
// Problem#: 1620
// Submission#: 1200290
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
using namespace std;
int main()
{
int T;
int N, M;
int C, P, S;
cin >> T;
while ( T-- ) {
cin >> N >> M >> C >> P >> S;
for ( int i = 0; i < S; i++ ) {
if ( C * ( S - i ) >= P ) {
N += M / P;
M %= P;
}
M += N * C;
}
cout << M << endl;
}
return 0;
}