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 |
虽然是水题,但是感觉自己的代码写得还不错,想贴一下,贴主要部分好了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