Model Crystal
Time limit1sMemory limit1024 MB
Given the number of sides A and a temperature drop B, count the minimal crystals in the growing regular polygon.
- Level
Medium6 of 10
- Topics
- Math, Implementation, Brute force, Geometry
- Solved
- No attempts yet
Statement
Jiyun discovered a strange material. The crystal of this material keeps the shape of a regular polygon, and each time the temperature drops by 1 degree, the number of crystals forming each side increases by 1. The first crystal consists of 1 crystal at 0 degrees Celsius. Call this crystal the minimal crystal.
The rules for the crystal growing in size are as follows. In the figure, the existing crystal is shown in blue, and the minimal crystals newly created at each temperature are shown in yellow.

- It keeps the shape of a regular A-gon. A regular A-gon means a regular polygon with A sides.
- Each time the temperature drops by 1 degree, the number of minimal crystals forming each side increases by 1.
- As few minimal crystals as possible attach to the existing crystal.
Jiyun wants to know the number of minimal crystals forming the crystal at a given temperature without actually lowering the temperature.
Write a program that prints the number of minimal crystals to help Jiyun.
Input
The first line gives the integers A (3 ≤ A ≤ 50) and B (0 ≤ B ≤ 10,000,000). A means the crystal's shape is a regular polygon with A sides, and B means the temperature is –B degrees Celsius.
Output
Print the number of minimal crystals when the crystal is a regular polygon with A sides and the temperature is –B degrees Celsius.