-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOFORTUNE.cpp
55 lines (46 loc) · 901 Bytes
/
OFORTUNE.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
Ad-hoc..interest calculation
*/
#include <cstdio>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while (t--) {
long int principle, tmp;
scanf("%ld", &principle);
int time, operations;
char ch[2];
scanf("%d%d", &time, &operations);
long long int interest, max = 0;
long double rate;
long int deduction;
while (operations--) {
scanf("%s%Lf%ld", ch, &rate, &deduction);
tmp = principle;
interest = 0;
if (ch[0] == '0') {
for (int i = 0;i < time;i++) {
interest += tmp * rate;
tmp -= deduction;
//printf("interest = %lld\n", interest);
}
tmp += interest;
if (tmp > max) {
max = tmp;
}
} else {
for (int i = 0;i < time;i++) {
interest = tmp * rate;
tmp += interest - deduction;
}
if (tmp > max) {
max = tmp;
}
}
}
printf("%lld\n", max);
}
return 0;
}