프로그램 명: coci_lju
제한시간: 1 초

[문제요약]M 개의 사탕이 있고 N 명의 아이들이 있다. N 명의 아이들이 요구하는 사탕수가 주어질 때 화(anger)의 합의 최소값을 구하는게 문제이다.

화(anger) = (사탕수 - 받은 사탕수)^2
만약 32 개의 사탕을 원했는데 29 개의 사탕을 받았다면 화의 양은 (32-29)^2 = 9 이다.

가지고 있는 사탕수는 아이들의 원하는 사탕수의 합 보다는 항상 더 적다.


Children in a kindergarten have received a large sack containing M candies. It has been decided that the candies are to be distributed among N children.

Each child has stated the number of candies that it wants. If a child isn’t given the amount of candy it wants, it will get angry. In fact it’ll get angrier for each candy it is deprived of. Some speculate that it’s anger will be equal to the square of the number of candy it is deprived of. For instance, if Mirko states that he wants 32 candies but receives only 29, he would be missing 3 candies, so his anger would be equal to 9.

Unfortunately, there is an insufficient amount of candy to satisfy all children. Therefore, the candies should be distributed in such a way that the sum of the children’s anger is minimal.

입력

출력

The first and only line of output must contain the minimum sum of the children’s anger. Note: The test cases will ensure that the result fits in a 64-bit unsigned integer: int64 in Pascal, long long in C/C++, long in Java.

입출력 예

입력

5 3
1
3
2

출력

1

입력

10 4
4
5
2
3

출력

4
출처:coci 2010

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]