![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
深蓝的回音
这个作者很懒,什么都没留下…
展开
-
【算法】 基础问题 继续(3n+1)猜想
原题为pta上的一道题:1005 继续(3n+1)猜想 一开始以为是动态规划,后面发现并不是… #include<iostream> using namespace std; int num[5000] = {0};//num数组用来储存每个数的计算次数,要注意开大一点,否则3n+1计算多几次就会越界 bool line[120] = {0};//line用来储存数列中的数是否存在,详情看main中的第一个for循环 void check(int n) { if(n == 1)//递归出原创 2021-06-02 17:20:13 · 155 阅读 · 0 评论 -
【算法】二叉树 已知中序和前序,求后序
题目来自洛谷:美国血统 American Heritage #include<iostream> #include<cmath> #include<string> #include<cstdio> using namespace std; string a,b;//a是中序,b是前序 void dfs(int l1,int l2,int l3,int l4){ //l1-l2是中序,l3-l4是前序 if(l1>l2||l3>l4)r原创 2021-06-02 11:40:02 · 152 阅读 · 0 评论