시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
5 초 128 MB 49 19 9 60.000%

문제

\(x_1, x_2, \dots, x_m\)을 어떤 정수 $a$와 $b$에 대해서 다음 조건을 만족하는 실수라고 하자. ($a>0$)

  1. \(-\frac{1}{\sqrt{a}} \le x_i \le \sqrt{a}\);
  2. \(x_1 + x_2 + \dots + x_m = b\times \sqrt{a}\)

이때, 짝수인 양의 정수 \(p\)가 주어졌을 때, \(x_1^p + x_2^p + \dots + x_m^p\)의 최댓값을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 $T$가 주어진다. 각 테스트 케이스는 한 줄이고, $m, p, a, b$로 이루어져 있다. ($m \le 2000, p \le 12, p$는 짝수)

항상 주어진 조건을 만족하는 \(x_1, x_2, \dots, x_m\)이 존재하는 경우만 입력으로 주어진다.

출력

각 테스트 케이스에 대해, 한 줄에 하나씩 문제에 주어진 식의 최댓값을 소수점 첫째자리에서 반올림해서 출력한다.

예제 입력 1

2
1997 12 3 -318
10 2 4 -1

예제 출력 1

189548
6
W3sicHJvYmxlbV9pZCI6IjM3NjkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWNkNWNcdWIzMTNcdWFjMTIiLCJkZXNjcmlwdGlvbiI6IjxwPlxcKHhfMSwgeF8yLCBcXGRvdHMsIHhfbVxcKVx1Yzc0NCZuYnNwO1x1YzViNFx1YjVhNCBcdWM4MTVcdWMyMTggJGEkXHVjNjQwICRiJFx1YzVkMCBcdWIzMDBcdWQ1NzRcdWMxMWMgXHViMmU0XHVjNzRjIFx1Yzg3MFx1YWM3NFx1Yzc0NCBcdWI5Y2NcdWM4NzFcdWQ1NThcdWIyOTQgXHVjMmU0XHVjMjE4XHViNzdjXHVhY2UwIFx1ZDU1OFx1Yzc5MC4gKCRhJmd0OzAkKTxcL3A+XHJcblxyXG48b2w+XHJcblx0PGxpPlxcKC1cXGZyYWN7MX17XFxzcXJ0e2F9fSBcXGxlIHhfaSBcXG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

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: h0ngjun7