#include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int S, T, N; cin >> S >> T >> N; array P{}, A{}, B{}; for (int i = 0; i < 3; ++i) { cin >> P[i] >> A[i] >> B[i]; } array pow100{}; pow100[0] = 1; for (int i = 1; i <= N; ++i) { pow100[i] = pow100[i - 1] * 100LL; } // Precompute the balance change caused by each outcome and wager. vector> change(T); for (int x = 1; x < T; ++x) { for (int i = 0; i < 3; ++i) { change[x][i] = -x + static_cast(1LL * A[i] * x / B[i]); } } vector prev(T, 0), cur(T, 0); auto action_value = [&](int w, int x, long long scale_prev) { long long total = 0; for (int i = 0; i < 3; ++i) { int next = w + change[x][i]; long long continuation = (next >= T) ? scale_prev : prev[next]; total += 1LL * P[i] * continuation; } return total; }; // Build optimal continuation values for 1, 2, ..., N-1 remaining wagers. for (int t = 1; t < N; ++t) { fill(cur.begin(), cur.end(), 0); long long scale_prev = pow100[t - 1]; for (int w = 1; w < T; ++w) { long long best = 0; for (int x = 1; x <= w; ++x) { best = max(best, action_value(w, x, scale_prev)); } cur[w] = best; } prev.swap(cur); } // Evaluate the first wager separately so every optimal first choice is reported. long long scale_prev = pow100[N - 1]; long long best = -1; vector optimal; for (int x = 1; x <= S; ++x) { long long value = action_value(S, x, scale_prev); if (value > best) { best = value; optimal.clear(); optimal.push_back(x); } else if (value == best) { optimal.push_back(x); } } cout << best / pow100[N - 1] << '\n'; cout << optimal.size() << '\n'; for (size_t i = 0; i < optimal.size(); ++i) { if (i) cout << ' '; cout << optimal[i]; } cout << '\n'; return 0; }