摘要: Input 输入单组数据。 每组数据都是一个可运行的C程序的源代码。 Output 为了简化问题,只需要你找出其中关键字“if”,“while”,“for”的数量即可(数量在1000以内)。 #include <stdio.h> #include <string.h> int main(int ar 阅读全文
posted @ 2019-02-20 21:43 Hello_World2020 阅读(480) 评论(0) 推荐(0) 编辑
摘要: 分析: 方案一: 从顶点出发,找到顶点权值最小minx=min(minx,c[i]) 边已经按照权值大小从小向大排列,edge[1...m] 每条边上权值 c[x]+c[y]+edge[i].w father[1...n]对点的标记,将所有点的标记都变成一个值,就实现了所有点的遍历 for(int 阅读全文
posted @ 2019-02-20 17:22 Hello_World2020 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 深搜: 一共有3个人,每个人有3种不同的动作,移动、举起旁边的人或扔出举起的人。所以加起来一共有9种不同的操作。 我们给这9中操作编码,分别为0~8,每次搜索都是从这8种不同的操作中选择一个操作进行下一次搜索。 搜索0,3,6时,即移动操作的时候,需要枚举他所能到达的所有地方。注意可以往前移动也可以 阅读全文
posted @ 2019-02-20 14:03 Hello_World2020 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 一:Perm算法 递归实现 #include <iostream> #include <cstring> using namespace std; int sum=0; template <class Type> inline void Swap(Type &a, Type &b) { Type t 阅读全文
posted @ 2019-02-20 13:54 Hello_World2020 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 技巧一:消去二进制最后一位数字1 公式: x & (x-1) 检测整数n是否为2的幂次,如果N是2的幂次,那么N&(N-1)得到结果为0,即可判断。 //检测整数n是否为2的幂次 #include<iostream> using namespace std; int main() { int n; 阅读全文
posted @ 2019-02-20 10:42 Hello_World2020 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 位转换 16转8 //16转8 #include <stdio.h> #include <string.h> char str[100005], num; void Fun(int i, int state) //长度 位数 { int temp; if(i < 0) { if(num != 0) 阅读全文
posted @ 2019-02-18 19:40 Hello_World2020 阅读(194) 评论(0) 推荐(0) 编辑
摘要: //树形动态规划 #include<iostream> #include<vector> using namespace std; int n; int w[100000+5]={0}; int vis[100000+5]={0}; int dp[100000+5][2]={0}; vector<i 阅读全文
posted @ 2019-02-18 18:40 Hello_World2020 阅读(378) 评论(0) 推荐(0) 编辑
摘要: 截取substr //string的操作 #include<iostream> using namespace std; int main() { string a,b; a="abcde"; b=a.substr(1); string c=a.substr(1,3); cout<<a<<endl; 阅读全文
posted @ 2019-02-18 17:39 Hello_World2020 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 十进制转换成二进制 //十进制转2进制 #include<iostream> using namespace std; int inttoBin(int num) { int i,tag=0; unsigned int mask = 0x80000000 ;//1000 0000 0000 0000 阅读全文
posted @ 2019-02-18 17:25 Hello_World2020 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 最大连续子数列和一道很经典的算法问题,给定一个数列,其中可能有正数也可能有负数,我们的任务是找出其中连续的一个子数列(不允许空序列),使它们的和尽可能大。 8-2 6 -1 5 4 -7 2 3第一行的8是说序列的长度是8,然后第二行有8个数字,即待计算的序列。对于这个序列,我们的答案应该是14,所 阅读全文
posted @ 2019-02-18 13:15 Hello_World2020 阅读(162) 评论(0) 推荐(0) 编辑