#P3712. Edges and More Edges

Edges and More Edges

Description

What is the maximum number of edges in an undirected graph G of n vertices that avoids a k-matching? Note that loops and parallel edges are not allowed in the graph.

Input

The input contains several test cases.
For each test case, there is one line with two positive integers, n ≤ 1000 and k ≤ 1000.
The input ends with two zeroes.

Output

For each test case output the maximum number of edges.

1000 1
500 2
0 0
0
499

Source

POJ Founder Monthly Contest – 2008.12.28

, Dagger