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 050501 at 2009-07-12 20:14:33 on Problem 2264
In Reply To:虽然是水题,但是感觉自己的代码写得还不错,想贴一下,贴主要部分好了 Posted by:czcomt at 2009-03-08 22:06:07
> void Dfs(int i, int j)
> {
> 	if (i == 0)
> 	{
> 		while (j != 0)
> 		{
> 			ans += b[j--];
> 		}
> 		return;
> 	}
> 
> 	if (j == 0)
> 	{
> 		while (i != 0)
> 		{
> 			ans += a[i--];
> 		}
> 		return;
> 	}
> 
> 	if (a[i] == b[j])
> 	{
> 		ans += a[i];
>         Dfs(i-1, j-1);
> 	}
> 	else
> 	{
> 		if (dp[i-1][j] < dp[i][j-1])
> 		{
> 			ans += a[i];
> 			Dfs(i-1, j);
> 		}
> 		else
> 		{
> 			ans += b[j];
> 			Dfs(i, j-1);
> 		}
> 	}
> }

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