2026: Divide the Birthday Cake
| Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
|---|---|---|---|---|---|
| 1s | 10240K | 482 | 223 | Standard |
On L.X.'s birthday, I bought her a big Birthday Cake, and she felt very happy.
"So how do you divide the cake?" I asked.
"I do not know. I do not want to simply divide it into several sectors. Hmn, Let me see. The cake is a little strange. Its shape looks like a polygon. En, I want to divide it into small pieces of triangles. I mean, if there are N sides, there should be N-2 small triangles. We can use N-3 diagonal(s) which do not intersect inside of the polygon to divide the cake into N-2 triangles." She said.
"Yeah, of course we can. It is an easy job." I took out a pencil and drew a dividing method on the paper.
"Yes. But I want to know how many different methods to divide the cake?" She smiled.
"Ah, it is not difficult. I will tell you the answer later!" said.
"Ok, but if you do not get the answer at last, you cannot eat the cake!"
"Ok…"
Then I began to calculate the number and she began to cut the cake. But I didn't get the answer, for there were 16 vertexes. Oh, I was hungry! You must help me!!!
Here are the examples of "VALID" and "INVALID" dividing method.
Input
There are several lines in the input file, each line contains a number N stands for the number the vertex of the polygon. 5<=N<=31. Your program should proceed to the end of the file.
Output
Print the number of dividing method one per line.
Sample Input
5 6
Sample Output
5 14
Problem Source: billjeff
This problem is used for contest: 7
Submit / Problem List / Status / Discuss
615

被折叠的 条评论
为什么被折叠?



