Back to Kernighan-RitchieInput:Standard InputOutput:Standard OutputYou must have heard the name ofKernighanandRitchie, the authors ofThe C Programming...
分类:
其他好文 时间:
2014-07-23 11:42:16
阅读次数:
298
我们可以把它直接考虑是个一维数组,对每个点向两边扩展,记录数据在数组中,
就是DFS
#include
int a[81],left,right;
void sort(int num,int pos)
{int x,y;
if (num!=-1)
{if (posright) right=pos;
a[pos]+=num;
s...
分类:
其他好文 时间:
2014-07-22 23:53:17
阅读次数:
266
Problem HHelp is needed for DexterTime Limit: 3 SecondDexter is tired of Dee Dee. So he decided to keep Dee Dee busy in a game. The game he planned fo...
分类:
其他好文 时间:
2014-07-22 23:26:57
阅读次数:
301
二分+并查集二分枚举边权,再用并查集判连通 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 const int MAXN=110; 8 const int MAXM=10100; 9 const ...
分类:
其他好文 时间:
2014-07-22 23:15:33
阅读次数:
264
UVA 11542 - Square
题目链接
题意:给定一些数字,保证这些数字质因子不会超过500,求这些数字中选出几个,乘积为完全平方数,问有几种选法
思路:对每个数字分解成质因子后,发现如果要是完全平方数,选出来的数字的每个质因子个数都必然要是偶数,这样每个质因子可以列出一个异或的方程,如果数字包含质因子,就是有这个未知数,然后进行高斯消元,求出自由变量的个数,每个自由变量...
分类:
其他好文 时间:
2014-07-22 22:38:34
阅读次数:
175
Problem DPiotr's AntsTime Limit: 2 seconds"One thing is for certain: there is no stopping them;the ants will soon be here. And I, for one, welcome ou....
分类:
其他好文 时间:
2014-07-22 22:36:53
阅读次数:
363
带状态的bfs用一个数(ks)来表示状态-当前连续穿越的障碍数;step表示当前走过的步数;visit数组也加一个状态; 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int max...
分类:
其他好文 时间:
2014-07-22 22:35:36
阅读次数:
214
二叉树? 怒水~~注意一下查询与x值的对应关系就好~ 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main (){ 7 char s[1000]; 8 int a[10],b[10]; 9 ...
分类:
其他好文 时间:
2014-07-22 22:35:35
阅读次数:
185
建树时就是碰到小写,就建个小树,左子树右子数都是空,压入栈;
碰到大写,也要建个小树,并把栈顶两个元素取出来,作为做子树和右子树。。在把新树压入栈
建完后栈顶就是这个树的根,采用广搜遍历就行。。...
分类:
其他好文 时间:
2014-07-22 18:04:33
阅读次数:
187
题解:可以根据输入的字符串画一个二叉树出来,然后层次遍历一下就和输出结果顺序一样,所以根据输入把大写字母当做两个小写字母的根节点,将节点即运算结果当做另一个小写字母放进栈里,和另一个字母组建生成新的树放进栈里,直到最后的的根节点也放进了栈里,开始层次遍历,用数组模拟队列进行遍历,注意因为结果的顺序是从右到左,所以注意遍历的方向问题。#include
#include
#include
#in...
分类:
其他好文 时间:
2014-07-22 17:49:42
阅读次数:
243