Description
Diligent farmer John wants to build a fence around them to keep the cows locked. He had a board of N (4<=n<=2500) that he wanted to cut into 4 pieces. These four pieces of planks can be any length as long as farmer John can surround them with a reasonable quadrilateral. He was able to cut out how many different kinds of reasonable solutions. Note: * As long as the cutting point of the board is different as a different scheme (like the whole arrangement), do not worry about another special case, go ahead. * Fence size is greater than 0.
* The output guarantees that the answer is within the Longint range. * The whole piece of wood must be run out.
Input
* First line: a number n
Output
* First line: Reasonable total number of programs
Sample Input6
Sample Output6
The output is detailed:
Farmer John was able to cut out all the cases for: (1, 1, 1,3); (1, 1, 2, 2); (1, 1, 3, 1); (1, 2, 1, 2); (1, 2, 2, 1); (1, 3, 1, 1);
(2, 1, 1, 2); (2, 1, 2, 1); (2, 2, 1, 1); or (3, 1, 1, 1).
The following four species-(1, 1, 1, 3), (1, 1, 3, 1), (1, 3, 1, 1), and (3,1, 1, 1)-cannot form a quadrilateral.
HINTSource
Qualifying Tournament
Solution
If the shortest three of the four line segments is longer than the longest segment, spicy will certainly make up the quadrilateral.
Enumerates the length of the first two edges, and the value range of the last two edges can be calculated.
1#include <bits/stdc++.h>2 using namespacestd;3 intMain ()4 {5 intN, a, b, ans =0;6CIN >>N;7 for(inti =1; I <= (n-1) >>1; i++)8 for(intj =1; J <= (N-1) >>1; J + +)9 {TenA = MIN (n-1) >>1, N-i-J-1); Oneb = N-i-J-A; AAns + = max (A-B +1,0); - } -cout << ans <<Endl; the return 0; -}
View Code
[BZOJ1600] [Usaco2008 OCT] Building Fences