Given an integer N and a pizza which can be cut into pieces, each cut should be a straight line going from the center of the pizza to its border. Also, the angle between any two cuts must be a positive integer. Two pieces are equal if their appropriate angles are equal. The given pizza can be cut in following three ways:
- Cut the pizza into N equal pieces.
- Cut the pizza into N pieces of any size.
- Cut the pizza into N pieces such that no two of them are equal.
The task is to find if it is possible to cut the pizza in the above ways for a given value of N. Print 1 if possible else 0 for all the cases i.e. print 111 if all the cases are possible.
Input: N = 4
Output: 1 1 1
Case 1: All four pieces can have angle = 90
Case 2: Same cut as Case 1
Case 3: 1, 2, 3 and 354 are the respective angles of the four pieces cut.
Input: N = 7
Output: 0 1 1
- Case 1 will only be possible if 360 is divisible by N.
- For case 2 to be possible, N must be ≤ 360.
- An ideal solution for case 3 would be to choose pieces in such a way that the angles they form are 1, 2, 3, … respectively. So, in order for this case to be possible, (N * (N + 1)) / 2 must be ≤ 360.
Below is the implementation of the above approach:
- Josephus Problem | (Iterative Solution)
- Number of stopping station problem
- CBSE Class 11 | Problem Solving Methodologies
- Program to print the Ladder Pattern
- Program to print the Diagonals of a Matrix
- How to Iterate through a String word by word in C++
- Difference between Public and Private in C++ with Example
- C++ Program to Illustrate Trigonometric functions
- How to erase an element from a vector using erase() and reverse_iterator?
- Check if two given Circles are Orthogonal or not
- C++ Program to print Fibonacci Series using Class template
- Minimum value to be assigned to the elements so that sum becomes greater than initial sum
- C-LOOK Disk Scheduling Algorithm
- Color all boxes in line such that every M consecutive boxes are unique
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.