TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Let x1, x2, ..., xm be real numbers satisfying the following conditions:



for some integers a and b (a > 0).



Determine the maximum value of x1p + x2p + … + xmp for some even positive integer p.

Input Format

Each input line contains four integers: m, p, a, b (m <= 2000, p <= 12, p is even OR p = 1). Input is correct, i.e. for each input numbers there exists x1, x2, …, xm satisfying the given conditions.

Output Format

For each input line print one number – the maximum value of expression, given above. The answer must be rounded to the nearest integer.

Sample Input 1

1997 12 3 -318
10 2 4 -1

Sample Output 1

189548
6

Hints

Problem Source

Migrated from old NTUJ.

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 200