Description
Maybe you've been complaining.
Maybe you're still sad
Maybe you're near.
Maybe you and I apart
For each of the students
Alma mater
Sailing Forever in
The Oceans of Life
This year is the 50 anniversary of our Hangzhou Electric Power Construction School, this is a blessed day. What kind of gift should we give to our alma mater? For the present, the best gift of course is the province of the good results, I can not compete, give the school a Doom III spherical big cake bar, this is a famous brand, estimated to spend half a year of silver.
Imagine the official anniversary of the day, the headmaster personally fencing, the big cake to all over to congratulate the alumni, we must be very happy, hehe, drool ...
Wait a minute, before eating the cake, we should take a question: If the headmaster has cut n knives on the cake (the headmaster has excellent cutting skill, each knife is an absolute plane), the ball cake can be cut into a few pieces.
Can't do this problem, no cake to eat.
For--The mother-school-, for---egg-cake-(Not for dgmm, maple feather Most will be the imagination ...) ), plus-oil-.
Input
The input data contains multiple test instances, one row per instance, each containing an integer n (1<=n<=1000), representing the number of knives cut.
Output
For each set of input data, output the corresponding number of cake blocks, one row for each test instance.
Sample Input
1
2
3
Sample Output
2
4
8
This problem is a step-by-step way:
(1) N-line most points plane problem
Topics such as: N straight lines, the maximum number of planes can be divided into areas.
Study Questions: Maybe you have seen this topic before, at best, it is a junior high school. But a type of topic or from a simple start, it is easy to find the law. When there are n-1 lines, the plane is divided up into F (n-1) regions. If the nth line is cut into the largest number of regions, it must intersect each line and cannot have the same intersection. This will give you a n-1 intersection. These intersections divide the nth line into 2-ray and n-2-line breaks. Each ray and line break will be divided into two regions. This will be more than the N-2 area.
Therefore: F (n) =f (n-1) +n
=f (n-2) + (n-1) +n
......
=f (1) +1+2+......+n
=n (n+1)/2+1
(2) Line sub-plane (hdu2050)
According to the line division plane, the number of rays and segments is determined by the intersection, and then the number of new regions is determined. When n-1 a polyline, the number of regions is f (n-1). In order to increase the maximum area, the segments on either side of the polyline intersect with the edge of the n-1 polyline, or the n-1 segment. The number of new segments is n-1 and the number of rays is 2. Note, however, that two segments adjacent to the polyline itself can only add one area.
Therefore: F (n) =f (n-1) +4 (n-1) +2-1
=f (n-1) +4 (n-1) +1
=f (n-2) +4 (n-2) +4 (n-1) +2
......
=f (1) +4+4*2+......+4 (n-1) + (n-1)
=2n^2-n+1
(3) Closed curve sub-plane problem
The topic is roughly as if there are N closed curves drawn on the plane, and any two closed curves intersect at two o'clock, and any three closed curves do not intersect at the same point, asking these closed curves to divide the plane into the number of regions.
Analysis: When n-1 a circle, the number of regions is f (n-1). Then the nth circle must intersect with the first n-1 circle, and the nth circle is divided into 2 (n-1) segments, adding 2 (n-1) regions.
Therefore: F (n) =f (n-1) +2 (n-1)
=f (1) +2+4+......+2 (n-1)
=n^2-n+2
(4) Plane partition space problem (hdu1290)
From the two-dimensional segmentation problem, it is known that the plane segmentation is related to the intersection of lines, that is, the intersection determines the number of rays and segments, thus determining the number of new regions. Imagine whether the three-dimensional is related to the plane of the intersection line. When there is a n-1 plane, the number of spaces divided is F (n-1). To have the largest number of spaces, the nth plane needs to intersect the first n-1 plane and cannot have a common intersection. That is, there are up to n-1 lines. The n-1 line divides the nth plane into a maximum of G (n-1) regions. (g (n) is the number of straight line planes in (1)) This plane divides the original space into two, and increases the space of G (n-1) up to a maximum.
Therefore: F=f (n-1) +g (n-1) ps:g (n) =n (n+1)/2+1
=f (n-2) +g (n-2) +g (n-1)
......
=f (1) +g (1) +g (2) +......+g (n-1)
=2+ (1*2+2*3+3*4+......+ (n-1) n)/2+ (n-1)
= (1+2^2+3^2+4^2+......+n^2-1-2-3-......-N)/2+n+1
= (n^3+5n)/6+1
#include <stdio.h>
int main ()
{
int n,s;
while (scanf ("%d", &n)!=eof)
{
s= (n*n*n+5*n+6)/6;
printf ("%d\n", s);
}
return 0;
}