Update dp_solver.cpp

Fixed a bug with the discounter
This commit is contained in:
Anthony Wang 2019-05-17 13:11:22 -05:00 committed by GitHub
parent 9742357efc
commit 7ed1f4d83d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}