上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 30 下一页
摘要: 水题一个,贴个代码吧。 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <string> #include <map> using namespace std; const 阅读全文
posted @ 2017-03-05 19:40 辰曦~文若 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 又是一道字符串处理的题目。。。 题意:给出两个浮点数,询问它们保留n位小数的科学计数法(0.xxx*10^x)是否相等。根据是和否输出相应答案。 思路:先分别将两个浮点数转换成相应的科学计数法的格式1.point为小数点的索引,初始化为字符串的长度len2.not0位第一个非0的数字的索引,初始化为 阅读全文
posted @ 2017-03-05 12:06 辰曦~文若 阅读(284) 评论(0) 推荐(1) 编辑
摘要: #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; const int maxn=100; char s1[maxn],s2[maxn],s3[maxn 阅读全文
posted @ 2017-03-03 15:46 辰曦~文若 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 水题,分组排序即可。 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; /* 太水水水。。。 */ const int maxn=100000+5; 阅读全文
posted @ 2017-03-03 15:44 辰曦~文若 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 由于是满二叉树,用数组既可以表示父节点是i,则左孩子是2*i,右孩子是2*i+1另外根据二分搜索树的性质,中序遍历恰好是从小到大排序因此先中序遍历填充节点对应的值,然后再层次遍历输出即可。 又是一道遍历的水题。。。 #include <iostream> #include <cstdio> #inc 阅读全文
posted @ 2017-03-02 11:35 辰曦~文若 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 第一眼以为是大数据,想套个大数据模板,后来发现不需要。因为A、B、C的大小为[-2^63, 2^63],用long long 存储他们的值和sum。 接下来就是分类讨论:如果A > 0, B < 0 或者 A < 0, B > 0,sum不会溢出,直接和C判断比较即可。如果A > 0, B > 0, 阅读全文
posted @ 2017-03-01 18:22 辰曦~文若 阅读(269) 评论(0) 推荐(1) 编辑
摘要: 贪心算法 次数最少的方法,即:1.每次都将0与应该放置在0位置的数字交换即可。2.如果0处在自己位置上,那么随便与一个不处在自己位置上的数交换,重复上一步即可。拿样例举例: 0 1 2 3 4 5 6 7 8 90:3 5 7 2 6 4 9 0 8 1 1:3 5 0 2 6 4 9 7 8 12 阅读全文
posted @ 2017-03-01 15:32 辰曦~文若 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 一开始没多想,虽然注意到数据N<=10^4的范围,想PAT的应该不会超时吧,就理所当然地用dfs做了,结果最后一组真的超时了。剪枝啥的还是过不了,就意识到肯定不是用dfs做了。直到看到别人说用01背包的思路,果真好久没做题了智力水平下降,且原本dp就是我的弱项,压根就没把这题往dp上去想额。。。 ( 阅读全文
posted @ 2017-03-01 14:53 辰曦~文若 阅读(1924) 评论(3) 推荐(2) 编辑
摘要: #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; /* 3 0 180 150 100 7.5 7.2 4.5 */ const int maxn=1 阅读全文
posted @ 2017-02-12 11:57 辰曦~文若 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 分割字符串的用法+map映射给出input中出现次数最多的单词,如果次数相同,给出按字典序最小的。 这里我用了自定义分隔符来读取字符串,方法如下: AC代码: #include <iostream> #include <cstdio> #include <algorithm> #include <s 阅读全文
posted @ 2017-02-12 11:51 辰曦~文若 阅读(262) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 30 下一页