判断是否存在欧拉(回)路,注意先要用并查集判断图是否连通。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 26; 7 const int M = 1001; 8 int f[N]; 9 in...
分类:
其他好文 时间:
2015-07-31 20:18:25
阅读次数:
116
水题,模拟。对于最后的方案数最多只会是2,想好久,又睡了一觉才想到这个,剩下的就好办了 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define lson l,m,rt<<...
分类:
其他好文 时间:
2015-07-31 20:17:18
阅读次数:
92
之前写过树状数组的,再用线段树写一下~~~ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define lp (p << 1) 9 #define rp (p <...
分类:
其他好文 时间:
2015-07-31 20:15:25
阅读次数:
122
我排第几个时间限制:1000ms | 内存限制:65535KB难度:3点我描述现在有"abcdefghijkl”12个字符,将其所有的排列中按字典序排列,给出任意一种排列,说出这个排列在所有的排列中是第几小的?输入第一行有一个整数n(0 2 #include 3 using namespace s....
分类:
其他好文 时间:
2015-07-31 20:06:30
阅读次数:
205
//k个机器人从一颗树的树根开始往下走,
//走树的每条边都要消耗能量,问这k个人最少花多少能量能遍历所有点
//dp[u][i] 表示以u点为根节点的子树用i个节点遍历最少需要多少能量
//当i = 0时表示有一个点遍历了这颗子树又返回上一个节点
#include
#include
#include
#include
using...
分类:
Web程序 时间:
2015-07-31 18:33:12
阅读次数:
139
Implement the following operations of a queue using stacks.
push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(...
分类:
其他好文 时间:
2015-07-31 18:29:47
阅读次数:
93
Implement the following operations of a stack using queues.
push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Return whet...
分类:
其他好文 时间:
2015-07-31 18:23:24
阅读次数:
77
#include #include using namespace std;#define maxn 100005#define lson rt>1; } int len() { return r-l+1; }} a[maxna[rt].Mid()) ...
分类:
其他好文 时间:
2015-07-31 18:00:05
阅读次数:
104
题目描述有n种不同大小的数字,每种各个。判断是否可以从这些数字之中选出若干使它们的和恰好为K。输入首先是一个正整数T(1 2 #include 3 #include 4 using namespace std; 5 int dp[100001],a[100001],m[100001]; 6 in.....
分类:
其他好文 时间:
2015-07-31 17:48:42
阅读次数:
87
题目描述对于正整数n,k,我们定义这样一个函数f,它满足如下规律现在给出n和k,你的任务就是要计算f(n,k)的值。输入首先是一个整数T,表示有T组数据 接下来每组数据是n和k(1 2 #include 3 int main() 4 { 5 using namespace std; 6 ...
分类:
其他好文 时间:
2015-07-31 17:45:52
阅读次数:
168