CF755D.PolandBall and Polygon

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

PolandBall has such a convex polygon with nn 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 kk such that gcd(n,k)=1gcd(n,k)=1 . Vertices of the polygon are numbered from 11 to nn in a clockwise way. PolandBall repeats the following process nn times, starting from the vertex 11 :

Assume you've ended last operation in vertex xx (consider x=1x=1 if it is the first operation). Draw a new segment from vertex xx to kk -th next vertex in clockwise direction. This is a vertex x+kx+k or x+knx+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.

输入格式

There are only two numbers in the input: nn and kk ( 5<=n<=1065<=n<=10^{6} , 2<=k<=n22<=k<=n-2 , gcd(n,k)=1gcd(n,k)=1 ).

输出格式

You should print nn values separated by spaces. The ii -th value should represent number of polygon's sections after drawing first ii lines.

输入输出样例

  • 输入#1

    5 2
    

    输出#1

    2 3 5 8 11 
  • 输入#2

    10 3
    

    输出#2

    2 3 4 6 9 12 16 21 26 31 

说明/提示

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

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

首页