题意:给你由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
??
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
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
题意:输入一个n,然后输入两个n*n矩阵,一个代表雷的矩阵,一个代表走过的的矩阵。然后输出结果矩阵、解题思路:结果矩阵分两种情况,一个是没有踩到雷的,一个是踩到雷的,踩到雷的要把雷都显示出来。其实就是用结构体的二维数组存的两个矩阵,然后输入,判断即可。具体代码:#include#include#in...
分类:
其他好文 时间:
2014-05-19 13:41:19
阅读次数:
220
DescriptionIn order to get from one of the F (1
2 and 1 –> 6 –> 5 –> 21 – 4: 1 –> 2 –> 3 –> 4 and 1 –> 6
–> 5 –> 43 – 7: 3 –> 4 –> 7 and 3 –> 2 –> 5 ....
分类:
其他好文 时间:
2014-05-19 12:43:06
阅读次数:
200