bzoj1643: 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:295 solved:250
[Submit] [Status] [Discuss] 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

Abuse problem, no difficulty happy ing ...

----------------------------------------------------------------------------

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <deque>
using namespace Std;
int dp[10005][5];
int main () {
int n;
scanf ("%d", &n);
Dp[0][0]=1;
for (int i=1;i<=n;i++)
for (int j=1;j<=4;j++)
for (int k=0;k*k<=i;k++) {
DP[I][J]+=DP[I-K*K][J-1];
}
printf ("%d\n", dp[n][4]+dp[n][1]+dp[n][2]+dp[n][3]);
return 0;
}

---------------------------------------------------------------------------

bzoj1643: 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.