#P60. [KBC005D] Article
[KBC005D] Article
Source
This problem is adapted from Long Long OJ. All rights reserved.
Problem Description
Zero likes to print articles using an old-fashioned printer.
One day, he wants to print an article with characters, where the size of the -th character is .
The cost of printing the article is calculated as follows:
- Printing each line incurs a paper cost of units, where is a constant.
- The ink cost for each line is the square of the sum of the sizes of all characters in that line.
Now, Zero wants to find the minimum cost required to print the article.
Input Format
This problem contains multiple test cases.
For each test case:
- The first line contains two positive integers .
- The next lines each contain a positive integer .
The input ends with EOF.
Output Format
For each test case, output a single line with an integer representing the minimum cost of printing the article.
Samples
5 5
5
9
5
7
5
4 3
1
1
1
1
230
14
Data Range
| Score Percentage | |
|---|---|
It is not guaranteed that the test case numbers are in ascending order of the data range.
For of the data: , , .
It is guaranteed that the total number of input numbers does not exceed .