临安农家乐做网站,北京移动网站建设公司排名,太平洋保险网站,广安建设机械网站今天也算是练习了一下记忆化搜索#xff0c;这道题也包含很多值得注意的地方 1、 输入的两个数不一定前者比后者大 2、 变换的过程中可能会超出int范围 3、 为了不超时可以作下预处理 #includeiostream#includecstring#includecstdiousing namesp… 今天也算是练习了一下记忆化搜索这道题也包含很多值得注意的地方 1、 输入的两个数不一定前者比后者大 2、 变换的过程中可能会超出int范围 3、 为了不超时可以作下预处理 #includeiostream#includecstring#includecstdiousing namespace std;#define MAXINT 1000001int res[MAXINT];int dfs(long long t){if(t1) return 1;if(tMAXINT res[t]!0) return res[t];if(tMAXINT) {if(t%20) return dfs(t/2)1;return dfs(3*t1)1; }if(t%20) res[t]dfs(t/2)1;else res[t]dfs(t*31)1;return res[t];}int main(){int i,m,n,temp,max;for(i1;i1000000;i) res[i]dfs(i);while(scanf(%d %d,n,m)!EOF) { printf(%d %d ,n,m);if(nm) tempn,nm,mtemp; max0;for(in;im;i) {if(maxres[i]) maxres[i]; } printf(%d\n,max); }return 0;} 转载于:https://www.cnblogs.com/yu-chao/archive/2012/02/28/2372043.html