摘要: #include <iostream>#include <string>#include <algorithm>using namespace std; void definition() //定义{ string str(5,'a'); cout << str <<endl; string str 阅读全文
posted @ 2020-02-10 19:33 sos3210 阅读(188) 评论(0) 推荐(0)
摘要: 为什么明明结果都可以到达那种情况,步骤不一样就不给通过 QAQ 有哪位大佬提点一下,在下感激不尽~~~ 我的代码: #include <iostream>#include <queue>#include <cstdio>#include <string>using namespace std;int 阅读全文
posted @ 2020-02-10 18:48 sos3210 阅读(313) 评论(0) 推荐(0)
摘要: 首先考虑没有限制的情况 当硬币被限制数量,需要加入对硬币情况的考虑 所以设dp[][] 记录凑齐x的种类 代码如下 #include <iostream>using namespace std;int main(){ int dp[251][101]={0},ans[251]={0}; int ty 阅读全文
posted @ 2020-02-09 21:56 sos3210 阅读(172) 评论(0) 推荐(0)
摘要: 这个嘛,我觉得是m[i]=max(m[0~i-1])+1;完了复杂度是O(n^2/2); 书上开了一个辅助数组d[],就很nice,思想是如果m[i]>d[最后一个],辣么直接添加进来, 如果m[i]<d[最后一个],就让它替换掉d[]中第一个比它大的,毕竟比它大的在前面,发展显然没有它好 当然也可 阅读全文
posted @ 2020-02-09 19:34 sos3210 阅读(122) 评论(0) 推荐(0)
摘要: 求公共最长子序列数目,这种类型不用多想,dp就完了(自我感觉最简单的dp) 首先确定状态,两串字符串比较,所以用二维的dp[i][j] 然后转移方程,当str1[i]=str2[j]时,由两字符串同时加一得到,dp[i][j]=dp[i-1][j-1]+1; 当str1[i]!=str2[j]时,d 阅读全文
posted @ 2020-02-09 18:17 sos3210 阅读(271) 评论(0) 推荐(0)
摘要: 这道题用dp解刚刚好(求最优解) 首先确定状态:dp[x],一个未知变量 状态转移方程:dp[x]=min(dp[x],dp[x-i]+(num[i~x]+10)*price[x]); 显然对于每个x都满足这个方程 初始化dp[0]=0,dp[x]=MAX; 从1到x用方程逐个求解 接下来放代码: 阅读全文
posted @ 2020-02-09 18:03 sos3210 阅读(467) 评论(0) 推荐(0)
摘要: 这是一个立方体的空间的路径搜索问题,若可达输出步数,不可达输出“NO ROUTE” 一道……课后题 输入的话我是按字符输入这个空间的 然后普通的bfs,一个方向数组,一个空间数组(因为只用一次,懒的再开一个,反正标记了,就是不能走的意思)引入某大佬的函数返回值做条件判重 需要注意的是,注意它的空间x 阅读全文
posted @ 2020-02-09 17:11 sos3210 阅读(183) 评论(0) 推荐(0)
摘要: set和map的底层模板是红黑树,可以有不同的键值和实值,关于增删改查,迭代器的使用都在代码里面,亲手尝试更方便记忆 #include <iostream>#include <map>#include <algorithm> //#include <functional>//不知道用来干什么 usi 阅读全文
posted @ 2020-02-02 20:55 sos3210 阅读(242) 评论(0) 推荐(0)
摘要: 注意: 1,回车和空格 2,是四位数,所以千位不能是0 接下来放代码 #include <iostream>#include <algorithm>using namespace std; int main(){ int arr[5]; cin >> arr[0] >> arr[1] >> arr[ 阅读全文
posted @ 2020-02-02 20:51 sos3210 阅读(267) 评论(0) 推荐(0)
摘要: 典型的模版题,很多方法可以解决,没什么难点,直接放代码了 #include <iostream>#include <queue>using namespace std;int n, k;bool look[100001];struct node { int n, step; node(int x=0 阅读全文
posted @ 2020-02-02 20:48 sos3210 阅读(185) 评论(0) 推荐(0)