1643: [Usaco2007 Oct]bessie ' s Secret pasture Bessie's Secret lawn

Source: Internet
Author: User

1643: [Usaco2007 Oct]bessie ' s Secret pasture Bessie's Secret lawn time limit:5 Sec Memory limit:64 MB
submit:268 solved:223
[Submit] [Status] Description

Farmer John has made a number of square turf from his ranch, the side length of the turf is always an integer (sometimes the farmer John cuts the turf of the knife is not appropriate, even cut out the side of the 0 square turf), he has put the turf in a cow Bessie already know the place. Bessie had always wanted to put the delicious turf in her secret manor, and she decided to take exactly 4 pieces out of the turf and move them into her secret manor, and then split them into 1x1 pieces, forming a portion of an area of N (1<=n<=10,000) units. Bessie was interested in the number of methods for selecting such four pieces of turf, and if she got a 4 unit area, she could have 5 different ways to choose 4 Turf: (1,1,1,1), (2,0,0,0), (0,2,0,0), (0,0,0,2). The order is valid: ( 4,3,2,1) and (1,2,3,4) are different methods.

Input

First line: A separate integer n.

Output

A separate line contains an integer representing the number of options that Bessie chose for four turf.

Sample Input4Sample Output5
HINT Source

Silver

The solving: hehe, a water DP (phile: This time no tease?) Hansbug:) ... Not much to say, the transfer equation is very simple, the code is very clear ...

1 var2 I,j,k,l,m,n:longint;3A:Array[0..4,0..20000] ofLongint;4 begin5 READLN (n);6Fillchar (A,sizeof (a),0);7       fori:=0  toTrunc (sqrt (n)) Do8a[1, i*i]:=1;9       fori:=2  to 4  DoTen           forj:=0  toN Do One               fork:=0  toTrunc (sqrt (j)) Do Aa[i,j]:=a[i,j]+a[i-1, j-k*K]; -Writeln (a[4, n]); -  the End. -           

1643: [Usaco2007 Oct]bessie ' s Secret pasture Bessie's Secret lawn

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.