Puzzle
Time limit1sMemory limit512 MB
Count rotation-distinct square puzzle pieces whose sides are each smooth, one of k tabs, or one of k blanks, classified into corners, borders, and normals.
- Level
Medium6 of 10
- Topics
- Combinatorics, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
Andrew is going to open his own factory for manufacturing puzzle pieces. He needs to order a special device that would cut pieces out of cardboard sheets. He also needs to order a set of tips for it. Each tip allows cutting pieces of a particular form.
A puzzle piece is a square, and each of its four sides can contain a rounded tab, a blank cut, or be smooth. The pieces can be of three different types:
- Corners: such pieces have exactly two adjacent smooth sides forming a corner.
- Borders: such pieces have exactly one smooth side.
- Normal: such pieces have no smooth sides.
Rounded tabs and blank cuts can each be of types. So there are options for a puzzle piece side: a rounded tab of one of types, a blank cut of one of types, or a smooth side.
Andrew needs to find out how many different tips he needs to order. Pieces such that one of them can be rotated to become equal to another one can obviously be cut out using the same tip.
Help Andrew find the number of different tips he needs to order so that he would be able to cut any possible puzzle piece.
Input
The only line of input contains an integer , the number of different rounded tab and blank cut types ().
Output
Output the number of different tips Andrew needs to order.
Notes
All tips for are presented in the picture below:
