아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Training Schedule for ICPC

시간 제한1초메모리 제한1024 MB

요약
훈련 n일과 휴식 m일을 n+m일에 배치해, 훈련 연속 구간 길이의 제곱 합에서 휴식 연속 구간 길이의 제곱 합을 뺀 값을 최대로 만든다.
난이도

보통10점 중 6점

유형
수학, 그리디, 동적 계획법, 구현
정답자
아직 제출이 없습니다

문제

With little time remaining until ICPC, you decided to reschedule your training plan. As maintaining both mental and physical vitality is important, you decided to spend n days of the remaining n + m days for training, and m days for repose. The question is which days should be used for the training and which for the repose. A schedule that increases your ICPC power more is better.

Training days increase the power, and consecutive training days are more effective. One day of training on the k-th day of consecutive training days increases the power by 2k − 1, where k = 1 for the first day of the consecutive training days. A single training day increases the power by only 1, but two consecutive training days increase it by 1 + 3 = 4, and three consecutive training days increase it by 1 + 3 + 5 = 9.

Repose days, on the other hand, decrease the power, and consecutive repose days decrease it more rapidly. One day of repose on the k-th day of consecutive repose days decreases the power by 2k − 1, where k = 1 for the first day of the consecutive repose days. A single repose day decreases the power by only 1, but two consecutive repose days decrease it by 1 + 3 = 4, and three consecutive repose days decrease it by 1 + 3 + 5 = 9.

Let us compute the largest increment of your ICPC power after n + m days of training and repose by the best training schedule. Note that, if you have too many repose days, this may be negative.

입력

The input consists of multiple datasets, each in the following format.

n m

Here, n and m are the numbers of training and repose days, respectively. Neither of them exceeds 106, and at least one of them is non-zero.

The end of the input is indicated by a line containing two zeros. The number of datasets does not exceed 100.

출력

For each of the datasets, output in a line the largest increment of ICPC power after n + m days of training and repose by the best training schedule.

예제1

  1. 예제 1

    입력
    1 1
    3 2
    6 1
    1 6
    0 3
    2 4
    7 9
    0 0
    
    예상 출력
    0
    7
    35
    -17
    -9
    -4
    10