A gift for the anniversary of hangdian
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 7597 accepted submission (s): 4145
Problem description you may have complained
Maybe you are still sad
Maybe you are close at hand
Maybe you and me
For every student
Alma mater
Always sail on
Ocean of life
This year marks the fifth anniversary of the establishment of the Hangzhou University. What kind of gift should we give to our alma mater? For the present, the best gift is of course a good result in the provincial competition. If I cannot participate in the competition, I will give the school a doom III spherical cake. This is a famous brand, it may take me half a year.
Imagine that on the day of the official celebration, the principal personally handed the cake to the alumni who came to congratulate each other. Everyone must be very happy...
Wait, let's take a look at the question before eating the cake: if the principal and adults cut n knives on the cake (the principal's knife method is superb, each knife is an absolute plane ), how many parts can this spherical cake be cut?
No cake to eat!
---Mother-School-, for---egg-cake-(not for dgmm, Feng Zhiyu will float the most to join...), add-oil -!
The input data contains multiple test instances. Each instance occupies one row and each row contains an integer N (1 <=n <= 1000), indicating the number of switches.
Output for each group of input data, please output the corresponding number of cake blocks, each test instance outputs a line.
Sample Input
123
Sample output
248
Code:
/* // Maximum split space in a plane: F (n) = f (N-1) + g (N-1); (G (N-1) = (N-1) * n/2 + 1); => F (n) = (N * n + 5 * N)/6 + 1; F (1) = 2; */# include <stdio. h> # include <string. h> int main () {int N; while (~ Scanf ("% d", & N) {printf ("% d \ n", (N * n + 5 * N)/6 + 1 );}}
Hdoj 1290 is a gift for the celebration of the anniversary of hangdian. [geometric template]