Hdoj 1290 is a gift for the celebration of the anniversary of hangdian. [geometric template]

Source: Internet
Author: User

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.