Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:虽然是水题,但是感觉自己的代码写得还不错,想贴一下,贴主要部分好了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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator