2221.cpp
来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 25 行
CPP
25 行
/* This Code is Submitted by wywcgs for Problem 2221 on 2006-05-14 at 18:48:53 */
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int fund, year, n, i, j;
while(scanf("%d %d %d", &fund, &year, &n) != EOF) {
int cpd, chg, best = 0; double rate;
for(i = 0; i < n; i++) {
scanf("%d %lf %d", &cpd, &rate, &chg);
int base = fund, ex = 0;
for(j = 0; j < year; j++)
if(cpd) base = base*(1+rate)-chg;
else { ex += base*rate; base -= chg; }
best = max(best, base+ex);
}
printf("%d\n", best);
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?