摘要: 输出一串数所能构成的所有等式,按照加数从大到小,算式从长到短排列一开始因为无法按照要求输出纠结了好一阵~~最后看了大神的代码才发现只需要每次dfs规定长度就好了~#include"cstdio"#include"cstring"#include"algorithm"#define MAXN 40us... 阅读全文
posted @ 2015-07-23 17:20 Septher 阅读(412) 评论(0) 推荐(0) 编辑
摘要: 选出三个数,让最大的数和最小的数之差不超过d~那只需要将所有数排序后,找出=low) { mid=low+(high-low)/2; if(num[mid]==n) return mid; else if(num[mid]>=n) high=mid-1; ... 阅读全文
posted @ 2015-07-23 17:16 Septher 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 这里要注意这么几点:1.人数要加上自己2.不能直接对半径进行二分,因为所求的是体积最大值,应该对半径的平方进行二分~解的范围是在0到最大半径的平方之间#include"cstdio"#include"cstring"#include"algorithm"#include"cmath"#define ... 阅读全文
posted @ 2015-07-23 17:10 Septher 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 稍微麻烦点的就是需要求导判断最小值的位置#include"cstdio"#include"cstring"#include"algorithm"#include"cmath"#define MAXN 505using namespace std;double cal(double x,double ... 阅读全文
posted @ 2015-07-23 17:07 Septher 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 关键是确定解的范围以及二分时的判断依据这里解的范围已经确定,因为是递增函数,二分依据就是和Y的大小比较#include"cstdio"#include"cstring"#include"algorithm"#include"cmath"#define MAXN 505using namespace ... 阅读全文
posted @ 2015-07-23 17:05 Septher 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 在三个数组中各选一个数,判断相加是否能得到目标数。一开始想暴力发现impossible~联系到二分,经过学长指点才将前两个数组合并,将前两个数组所有可能的和保存在新数组中,再根据第三个数组,二分查找新数组以判断是否有所需的数#include"cstdio"#include"cstring"#incl... 阅读全文
posted @ 2015-07-23 16:57 Septher 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 可以理解为判断连通块的个数~~DFS解决#include"cstdio"#include"iostream"#include"cstring"#define MAXN 105using namespace std;int mat[MAXN][MAXN],vis[MAXN][MAXN];int dfs... 阅读全文
posted @ 2015-07-23 16:50 Septher 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 可以理解为象棋中的马走“日”字形,从第一个位置到第二个位置所需的最短步数,简单的BFS每走一步需判断一次是否到达目标点。由于BFS写得不多,一直用DFS的思维理解,递归写一直溢出、超时~~#include"cstdio"#include"iostream"#include"cstring"#incl... 阅读全文
posted @ 2015-07-23 16:49 Septher 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 题面描述了一种加密的方式,让coder按照要求解密~将字母分成三段,再将位置用数组储存~所谓的旋转其实就是右移~#include"cstdio"#include"iostream"#include"cstring"using namespace std;int main(){ int k1,k2... 阅读全文
posted @ 2015-07-23 16:45 Septher 阅读(200) 评论(0) 推荐(0) 编辑
摘要: #include"cstdio"#include"iostream"#include"cstring"using namespace std;char H[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax... 阅读全文
posted @ 2015-07-23 16:42 Septher 阅读(129) 评论(0) 推荐(0) 编辑