A10690 | PolandBall and Polygon
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
There are only two numbers in the input: $n$ and $k$ ( $5<=n<=10^{6}$ , $2<=k<=n-2$ , $gcd(n,k)=1$ ).
输出格式
You should print $n$ values separated by spaces. The $i$ -th value should represent number of polygon's sections after drawing first $i$ 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 $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.

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

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted