题目链接题意 : 一个m面的骰子,掷n次,问得到最大值的期望。思路 : 数学期望,离散时的公式是E(X) = X1*p(X1) + X2*p(X2) + …… + Xn*p(Xn)p(xi)的是所有最大值是xi的情况数/总情况数一共是m^n种,掷n次,所有最大值是xi的情况数应该是xi^n,但是这里...
分类:
其他好文 时间:
2014-08-05 10:44:59
阅读次数:
217
(1)不要使用new Array(),new Number, new String, or new Boolean. 等等如果要新建数组,没有必要使用new Array(),使用[];原因是直观。(2)不要使用new Function 来创建函数如果要写代码:myObj = new function...
分类:
Web程序 时间:
2014-08-05 10:41:49
阅读次数:
477
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key.Th...
分类:
其他好文 时间:
2014-08-05 09:43:39
阅读次数:
191
Welcome back! This post deals with the second half of pixel processing, the “join phase”. The previous phase was all about taking a small number of i....
分类:
其他好文 时间:
2014-08-05 00:37:58
阅读次数:
305
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1227
#include
#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 200 + 1; //the number of restaurants
const i...
分类:
其他好文 时间:
2014-08-04 21:42:58
阅读次数:
252
487-3279
Businesses like to have memorable telephone numbers. One way to make a telephone number memorableis to have it spell a memorable word or phrase. For example, yo...
分类:
其他好文 时间:
2014-08-04 21:41:34
阅读次数:
395
我们把只包含因子2、3和5的数称作丑数(Ugly
Number)。例如6、8都是丑数,但14不是,因为它包含因子7。
方法1 :
暴力破解,逐个判断
代码:
#include
#include
using namespace std;
//判断是否是丑数
bool isUgly(int index){
while(index % 2 == 0){
index /= 2...
分类:
其他好文 时间:
2014-08-04 21:30:58
阅读次数:
313
--利用sqlserver来运算斐波那契规律declare @number intdeclare @A intdeclare @B intdeclare @C intset @A=1set @B=2set @Number=3select @C=@A+@Bwhile(@Number0) goto er...
分类:
数据库 时间:
2014-08-04 21:23:58
阅读次数:
279
Given a digit string, return all possible letter combinations that the number could represent.
分类:
其他好文 时间:
2014-08-04 21:20:47
阅读次数:
257
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711题目大意:在母链中找到子链的位置,输出开始的位置。 1 #include 2 #include 3 using namespace std; 4 int lens,lenc,next[10000.....
分类:
其他好文 时间:
2014-08-04 21:17:57
阅读次数:
174