摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4432代码:#include#include#include#includeusing namespace std;int sum;int n,k;int tranfer(int num){ int ret = 0; while(num > 0) { int a = num%k; num = num/k; ret += a*a; } return ret;}int main(){ // freopen("E:\\acm\\i... 阅读全文
posted @ 2013-10-06 19:14 等待最好的两个人 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4433题目大意:给你一连串密码,(密码是0-》9循环转动),求最少的步骤到达目标数码。算法思路:这个题一看就觉得要用dp思想,就是方程不好想,抓住题目给的可以连续拨动1-3密码,我的dp[i][j][k]表示第i个数字为j,第i+1个数字为k,i及以后到达目标所有的最少步骤。然后记忆化搜。代码:#include#include#include#includeusing namespace std;int dp[1050][10][10];char in[1050],out[1050];int len 阅读全文
posted @ 2013-10-06 19:05 等待最好的两个人 阅读(306) 评论(0) 推荐(0) 编辑