Wonky Pizza

Illustration of Sample Input 1. The first cut at $\theta =0$ is along the solid blue line, and the second cut at $\theta \approx 3.74633$ is along the dashed blue line. Together, the cuts split the pizza into two pieces of equal area.

As is customary at the ACPC, there will be pizza.1 However, due to logistical challenges, the only pizza available is a wonky pizza. The organizers will buy one wonky pizza and need to cut it into $N$ pieces, one for each of the $N$ contestants. The organizers will have to fight over who gets to eat the napkins.

A wonky pizza is like a regular pizza, except that at an angle of $\theta $ radians (measured counter-clockwise) from the positive $x$ axis, the shape extends $\frac{\alpha \theta }{2\pi }+\beta $ units from the origin, for some $\alpha $ and $\beta $ (in contrast, a normal pizza extends $r$ units from the origin at every angle $\theta $, where $r$ is the radius of the pizza).

Each cut will follow a straight line from the origin to the outer boundary, so cutting straight across the entire pizza would require two cuts. The first cut will be made at an angle of $0$ radians. Determine what angles to make the remaining $N-1$ cuts at to split the pizza into $N$ pieces of equal area.


The input consists of a single line with three numbers, $\alpha $, $\beta $, and $N$, where $0\le \alpha ,\beta \le 10$, and $N$ is an integer with $2\le N\le 100$. It is guaranteed that $\alpha $ and $\beta $ are not both zero.


The output should consist of $N-1$ lines, where the $i^{th}$ line contains the angle of cut $i$ in radians. The angles should be specified in order from smallest to largest. Your answer will be considered correct if its absolute or relative error doesn’t exceed $10^{-4}$.

Sample Input 1 Sample Output 1
0.5 1 2
Sample Input 2 Sample Output 2
3 2 5


  1. Except in 2020 and 2021.
CPU Time limit 1 second
Memory limit 1024 MB
Difficulty 5.1Medium
Statistics Show
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in