05 2020 档案

摘要:此题的策略是选取可用范围最右边的点,一般来说该点辐射两边,左侧辐射,右侧辐射,所以用两个循环,第一个循环找出该点,第二个循环求出最右边的点 源代码: #include<iostream>#include<algorithm>using namespace std;#define maxn 1100i 阅读全文
posted @ 2020-05-29 20:40 Joelin12 阅读(169) 评论(0) 推荐(0)
摘要:方法:将S逆序与S正序相比较,谁小加哪个 源代码 #include<iostream>#include<iomanip>#include<cstdio>#include<cmath>#include<vector>#include<cstdlib>#include<algorithm>using n 阅读全文
posted @ 2020-05-29 18:14 Joelin12 阅读(114) 评论(0) 推荐(0)
摘要:本题的关键是从可选择方法中选择哪一类最优化 答案是结束时间最早的一类 源代码 #include<iostream>#include<algorithm>#include<cstdio>#define maxn 100100using namespace std;struct w{ int endd, 阅读全文
posted @ 2020-05-29 13:16 Joelin12 阅读(136) 评论(0) 推荐(0)
摘要:贪心法遵从某种规则,不断贪心优化过程,此题规则就是优先选择面值大的硬币 源代码 #include<iostream>#include<cstdio>using namespace std;int main(){ int V[]={1,5,10,50,100,500}; int num=0,money 阅读全文
posted @ 2020-05-29 11:50 Joelin12 阅读(180) 评论(0) 推荐(0)
摘要:宽度优先搜索运用了队列(queue)在unility头文件中 源代码 #include<iostream>#include<cstdio>#include<queue>#include<algorithm>#include<utility>using namespace std;typedef pa 阅读全文
posted @ 2020-05-29 11:27 Joelin12 阅读(259) 评论(0) 推荐(0)
摘要:#include<iostream>#include<cstdio>#include<cstdlib>#define maxn 100char ch[maxn][maxn];using namespace std;int length,width;void dfs(int x,int y){ ch[ 阅读全文
posted @ 2020-05-28 11:54 Joelin12 阅读(115) 评论(0) 推荐(0)
摘要:#include<iostream>#include<stack>#define maxn 30using namespace std;stack<int>st;int n,k,a[maxn];bool dfs(int i,int sum){ if(i==k) return sum==k;//加到最 阅读全文
posted @ 2020-05-28 10:47 Joelin12 阅读(104) 评论(0) 推荐(0)
摘要:链接:https://vjudge.net/problem/UVA-524 题意:给出正整数n,输出以1开头,由2到n组合的字符序列,使相邻的数相加为素数,最后一个(关键信息为n大于1小于等于16),于是可以枚举出来素数可能的个数,然后用set中的count判断是否有素数,这里需要用到n重循环,所以 阅读全文
posted @ 2020-05-09 14:46 Joelin12 阅读(145) 评论(0) 推荐(0)
摘要:01-复杂度2 Maximum Subsequence Sum (25分) Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, 阅读全文
posted @ 2020-05-08 09:36 Joelin12 阅读(146) 评论(0) 推荐(0)
摘要:题目: 最大连续子数列和一道很经典的算法问题,给定一个数列,其中可能有正数也可能有负数,我们的任务是找出其中连续的一个子数列(不允许空序列),使它们的和尽可能大。我们一起用多种方式,逐步优化解决这个问题。 为了更清晰的理解问题,首先我们先看一组数据:8-2 6 -1 5 4 -7 2 3 输出 14 阅读全文
posted @ 2020-05-07 23:26 Joelin12 阅读(264) 评论(0) 推荐(0)
摘要:链接: 题意:输入一些单词,找出所有满足如下条件的单词:该单词不能通过字母重排,得到输入文本的另外一个单词。在判断是否满足条件时,字母不分大小写,但在输出时应保留输入的大小写,按字典序排列。 题解:先对输入的单词进行小写化,然后进行排序,如果排序后的字符串相同,那么就剔除。此处建议用map<stri 阅读全文
posted @ 2020-05-07 16:18 Joelin12 阅读(230) 评论(0) 推荐(0)
摘要:链接:https://vjudge.net/problem/UVA-10815#author=0 题意:给几段句子,按字典序筛选出单词。 题解:用C的话太麻烦,不如用自动去重并排序的set容器。有个地方需要考虑,就是单词连接着(:“)。这被看来是一个string。所以非字母的的要先变为空格。因为st 阅读全文
posted @ 2020-05-07 15:04 Joelin12 阅读(351) 评论(0) 推荐(0)