aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTa180m2019-05-17 13:11:22 -0500
committerGitHub2019-05-17 13:11:22 -0500
commit7ed1f4d83d957c7c8397a6285b0763b8c8b81ddf (patch)
treec3474ba5893120a3d579af18e89533622d9f4d55
parent9742357efca6304b2167c66b4c18dc9ace7e1d65 (diff)
Update dp_solver.cpp
Fixed a bug with the discounter
-rw-r--r--dp_solver.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/dp_solver.cpp b/dp_solver.cpp
index a5d4711..fa33420 100644
--- a/dp_solver.cpp
+++ b/dp_solver.cpp
@@ -137,9 +137,9 @@ int main() {
}
// Buy the rebooter
- if (R == 0 && DP[i] - pcost(1, DP[i]) > DP[i - i % 9 + 9]) {
- DP[i - i % 9 + 9] = DP[i] - pcost(1, DP[i]);
- pre[i - i % 9 + 9] = i;
+ if (R == 0 && DP[i] - pcost(1, DP[i]) > DP[i - i % 36 + 9]) {
+ DP[i - i % 36 + 9] = DP[i] - pcost(1, DP[i]);
+ pre[i - i % 36 + 9] = i;
}
// Buy the mini bonus
@@ -206,16 +206,16 @@ int main() {
cout << "Buy the Level " << M << " (x" << format(val[2][M]) << ") multiplier for $" << format(cost[D][2][M]) << ", making your total $" << format(DP[output[i]]) << endl;
}
- // Buy the discounter
- else if (D != (output[i - 1] / 18) % 2) {
- cout << "Buy and use the discounter for $" << format(pcost(0, DP[output[i - 1]])) << ", making your total $" << format(DP[output[i]]) << endl;
- }
-
// Buy the rebooter
else if (R != (output[i - 1] / 9) % 2) {
cout << "Buy and use the rebooter for $" << format(pcost(1, DP[output[i - 1]])) << ", making your total $" << format(DP[output[i]]) << endl;
}
+ // Buy the discounter
+ else if (D != (output[i - 1] / 18) % 2) {
+ cout << "Buy and use the discounter for $" << format(pcost(0, DP[output[i - 1]])) << ", making your total $" << format(DP[output[i]]) << endl;
+ }
+
// Buy the mini bonus
else if (B1 != (output[i - 1] / 3) % 3) {
cout << "Buy the mini bonus for $" << format(pcost(2, DP[output[i - 1]])) << ", making your total $" << format(DP[output[i]]) << endl;
@@ -232,3 +232,4 @@ int main() {
}
else cout << "No strategy to reach $" << format(goal) << " from $" << format(start) << " in " << max_it << " iterations could be found" << endl;
}
+