Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:献上我的第一次

Posted by joy_w at 2009-08-28 20:23:59 on Problem 1221
In Reply To:献上我的第一次 Posted by:z1160y at 2009-06-11 15:11:20
也献上一次;和楼上思想基本一样儿一样儿的。。(dp+记忆化搜索版+简化版)
#include<iostream>
using namespace std;

__int64 dp[255][255];
__int64 joy_dp(int a,int k)
{
	if(dp[a][k]>0) return (dp[a][k]);
	if(a==k) return (dp[a][a]=1);
	if(a<k) return 0;
	if(a>=2*k) return (dp[a][k]=joy_dp(a-2*k,k)+joy_dp(a,k+1));	
	else return(dp[a][k]=joy_dp(a,k+1));
}
int main()
{
	for(int i=0;i<255;i++) dp[0][i]=1;

	int n;
	while(scanf("%d",&n)&&n)  printf("%d %I64d\n",n,joy_dp(n,1));
return 0;}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator