Not so MobileBefore being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. Th....
分类:
其他好文 时间:
2014-07-18 13:34:02
阅读次数:
242
建立两个数组同时存储原学校与目标学校。分别按优先原学校和优先目标学校排序,一一配对,验查是否可行。 1 #include 2 #include 3 using namespace std; 4 5 struct node { 6 int x,y; 7 }a[500010],b[5000...
分类:
其他好文 时间:
2014-07-18 12:29:12
阅读次数:
171
Dropping BallsA number of K balls are dropped one by one from the root of a fully binary tree structure FBT. Each time the ball being dropped first v....
分类:
其他好文 时间:
2014-07-18 12:14:24
阅读次数:
202
下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成。打牢基础,厚积薄发。一、UVaOJhttp://uva.onlinejudge.org西班牙Valladolid大学的程序在线评测系统,是历史最悠久、最著名的OJ。二、《算法...
分类:
其他好文 时间:
2014-07-18 11:39:04
阅读次数:
483
这道题涉及次小生成树,有必要先弄明白次小生成树是怎么一回事。次小生成树,顾名知义。一个定理是,次小生成树可以由最小生成树交换一条边得到。这怎么证明,可以上网搜一下。但有必要提醒的是,交换过来的这样一条边,必须是未成使用过的(即不是最小生成树的边)。而且,交换走的边,必须是已存在的,而且是两点间最短路...
分类:
其他好文 时间:
2014-07-18 10:32:56
阅读次数:
325
UVA 11291 - Smeech
题目链接
题意:给定一个表达式形如e=(p,e1,e2)
该表达式的值为 p?(e1+e2)+(1?p)?(e1?e2),求出值
思路:题目是很水,但是处理起来还挺麻烦的,模拟写编译器LEX分析器原理去写了。
代码:
#include
#include
const int N = 100005;
char str[N];...
分类:
其他好文 时间:
2014-07-17 21:07:29
阅读次数:
170
UVA 12230 - Crossing Rivers
题目链接
题意:给定几条河,每条河上有来回开的船,某一天出门,船位置随机,现在要求从A到B,所需要的期望时间
思路:每条河的期望,最坏就是船刚开走3L/V,最好就是直接上船L/V,期望为4L/V/2 = 2L/V,然后在算上陆地上的时间,就是答案
代码:
#include
#include
int n;
d...
分类:
其他好文 时间:
2014-07-17 19:29:44
阅读次数:
223
Trie+DP
大白书上的字典树训练题。
题意是说一个字符串可能有多少种小串组成。
例如
abcd
4
a
b
cd
ab
abcd=a+b+cd;abcd=ab+cd;
递推为:从最后一位往前,dp[i]=dp[i]+dp[i+ len[x]] x为输入时的顺序,附加到节点中。是 i~strlen(S)的前缀。S[1,2,3,…,i,…len]
...
分类:
其他好文 时间:
2014-07-17 19:26:33
阅读次数:
277
UVA 10288 - Coupons
题目链接
题意:n个张票,每张票取到概率等价,问连续取一定次数后,拥有所有的票的期望
思路:递推,f[i]表示还差i张票的时候期望,那么递推式为
f(i)=f(i)?(n?i)/n+f(i?1)?i/n+1
化简后递推即可,输出要输出分数比较麻烦
代码:
#include
#include
#include
lon...
分类:
其他好文 时间:
2014-07-17 19:12:07
阅读次数:
189
Factovisors
The factorial function, n! is defined thus for n a non-negative integer:
0! = 1
n! = n * (n-1)! (n > 0)
We say that a divides b if there exists an integer k such that
k*a =...
分类:
其他好文 时间:
2014-07-17 19:05:06
阅读次数:
235