Project Euler #190: Maximising a weighted product

  • + 1 comment

    X, A and m:
    x_1 + x_2 + .. + x_m = X
    a_1 + a_2 + .. + a_m = A
    For a given (a_1, a_2, .. a_m), to maximize x_1^a_1 * x_2^a_2 * ... * x_m^a_m, which is Qm(X, (a_1, a_2, .. a_m)).

    Question:
    When trying to find Qm(X, (a_1, a_2, .. a_m)), is there an existing formula to get Qm(X, (a_1, a_2, .. a_m)), or we need to calculate x_1^a_1 * x_2^a_2 * ... * x_m^a_m for all (x_1, x_2, .. x_m) combinations?