8VC Venture Cup 2017 - Elimination Round
D
PolandBall and Polygon
Codeforces
2000
原题
← CE →
翻译中…

PolandBall has such a convex polygon with $*n*$ veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.

翻译中…

He chose a number $*k*$ such that $*gcd*(*n*, *k*) = 1$. Vertices of the polygon are numbered from $1$ to $*n*$ in a clockwise way. PolandBall repeats the following process $*n*$ times, starting from the vertex $1$:

翻译中…

Assume you've ended last operation in vertex x (consider x = 1 if it is the first operation). Draw a new segment from vertex x to k-th next vertex in clockwise direction. This is a vertex x + k or x + k - n depending on which of these is a valid index of polygon's vertex.

翻译中…

Your task is to calculate number of polygon's sections after each drawing. A section is a clear area inside the polygon bounded with drawn diagonals or the polygon's sides.

翻译中…

Input

翻译中…

There are only two numbers in the input: $*n*$ and $*k*$ ($5 ≤ *n* ≤ 10^{6}$, $2 ≤ *k* ≤ *n* - 2$, $*gcd*(*n*, *k*) = 1$).

翻译中…

Output

翻译中…

You should print $*n*$ values separated by spaces. The $*i*$-th value should represent number of polygon's sections after drawing first $*i*$ lines.

翻译中…

Note

翻译中…

The greatest common divisor (gcd) of two integers $*a*$ and $*b*$ is the largest positive integer that divides both $*a*$ and $*b*$ without a remainder.

翻译中…

For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.

翻译中…

image image image image image image

翻译中…

样例

Input #1
5 2
Output #1
2 3 5 8 11
InputCopy OutputCopy
Input #2
10 3
Output #2
2 3 4 6 9 12 16 21 26 31
InputCopy OutputCopy
题目信息
题号
755D
时间限制
4 s
内存限制
256 MB
标签
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。