题意:给你由N个点构成一颗树,问要孤立出一个有P个节点的子树最少需要删除多少条边。N的范围最大为150N的范围不大,很容易想到在树上面做背包。把每个节点都看成一个背包,然后把每个儿子节点都看成是一组物品。为什么是一组呢,那是因为假设以儿子为根的节点的子树有S个节点,那么就有S+1种情况,要么将这整棵...
分类:
其他好文 时间:
2014-05-23 10:05:26
阅读次数:
276
??
Printer Queue
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 3679
Accepted: 1975
Description
The only printer in the computer science students' union is...
分类:
其他好文 时间:
2014-05-23 08:05:45
阅读次数:
273
题意:推箱子的题目,求最短的路径,如果推的最短一样的话,就算上走的最短
思路:首先我们记录状态:箱子的位置和人的位置,我们先BFS箱子的最短,然后我们可以通过推的方向得到人的位置,然后再BFS人是否能到这里的最短路#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 50;
...
分类:
其他好文 时间:
2014-05-22 10:57:35
阅读次数:
292
??
Terrible Sets
Time Limit: 1000MS
Memory Limit: 30000K
Total Submissions: 2999
Accepted: 1549
Description
Let N be the set of all natural numbers {0 , 1 , 2 , . . . ...
分类:
其他好文 时间:
2014-05-22 09:52:10
阅读次数:
283
Nearest number - 2
Description
Input is the matrix A of N by N non-negative integers....
分类:
其他好文 时间:
2014-05-22 09:38:33
阅读次数:
236
POJ 2773 Happy 2006
题目大意:
给定m,k,问你第K个与m互质的数是多少? 其中 m (1 <= m <= 1000000), K (1 <= K <= 100000000).
解题思路:
用位运算的容斥原理,计算 [1,x]与m互质的数的方法是:
假设 m的质因数为 a,b,c ,那么与m不互斥的数个数为 f(a)+f(b)+f(c)-f(ab)-f(ac)-fa(bc)+f(abc),f(t)的含义是 (1,x)有多少个数与t不互质,很明显f(t)=x/t,那么与m互...
分类:
移动开发 时间:
2014-05-20 13:50:30
阅读次数:
291
Cash MachineTime Limit:1000MSMemory
Limit:10000KTotal Submissions:26172Accepted:9238DescriptionA Bank plans to
install a machine for cash withdrawal. ...
分类:
其他好文 时间:
2014-05-20 10:55:48
阅读次数:
270
http://poj.org/problem?id=3164第一次做最小树形图,看着别人的博客写,还没弄懂具体的什么意思。 1 #include 2
#include 3 #include 4 #include 5 #define maxn 1000 6 using namesp...
分类:
Web程序 时间:
2014-05-20 09:39:34
阅读次数:
324
Communication SystemTime Limit: 1000MSMemory Limit:
10000KTotal Submissions: 22445Accepted: 7977DescriptionWe have received an order
from Pizoor Comm....
分类:
其他好文 时间:
2014-05-20 07:37:17
阅读次数:
454