生成满足一定分布的随机数,是统计模拟、系统仿真等应用中最基本的要求。matlab中提供了函数可以生成各种常见分布的随机数,c++使用boost random库也可以很容易实现。一、例子boost random库的文档提供了一个例子,模拟掷色子。投掷一个均匀的色子,六个面每个面出现的概率应该是相等的,...
分类:
其他好文 时间:
2014-07-22 22:55:55
阅读次数:
240
让UIWebView的背景透明:12self.webView.backgroundColor = [UIColor clearColor];self.webView.opaque = NO这样就可以背景透明了,如果还是无效的话,那么需要在html里面加入: 去掉uiwebview滚动到边缘时的阴影....
分类:
Web程序 时间:
2014-07-18 14:26:56
阅读次数:
223
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4790
题目大意:给出a,b,c,d,p,m,在[a,b]和[c,d]中分别选一个数x,y。问满足(x+y)%p=m的(x,y)有多少组,求出占总组数的比例
首先,当然是想遍历一遍,统计满足的有多少点,如此便能轻松愉快的解出此题;但是,真的是这样吗?
我们看一下数据范围,范围是10^9,如果两个数...
分类:
其他好文 时间:
2014-07-18 11:01:26
阅读次数:
187
编写脚本生成2位的随机数,要求个位和十位数不能相同,如果遇到个位和十位相同的就退出脚本,注意十位数不能为0count=0whiletruedonum=$((RANDOM%100))if((((num/10))==0))thencontinueelseif((((num%10))==((num/10))))thenbreakelseechonum:$num((count++))fifidoneecho"succ..
分类:
其他好文 时间:
2014-07-17 09:43:57
阅读次数:
236
echo"大家猜猜0-9的随机数,你一共有3次机会"count=2n=$((RANDOM%10))while((count>=0))doread-p"pleaseinput:"numif(($n==$num))thenecho"congratulation!随机数是$n,你总共猜了$((3-$count))次"exitelif((n<num))thenif(($count==0))thenecho-n"high"elseecho"high,还..
分类:
其他好文 时间:
2014-07-17 09:04:28
阅读次数:
232
设置时效:1分钟HttpSession session=ServletActionContext.getRequest().getSession(true); session.setAttribute("random", random); session.setMaxIn...
分类:
其他好文 时间:
2014-07-16 18:40:37
阅读次数:
167
Math.round(x) 四舍五入 加上0.5向下取整 Math.round(1.5) 2 Math.round(-11.5) -11 Math.round(-11.2) -10Math.ceil(x) 不小于x的最小整数 Math.ceil(1.5) 2 Math.ceil...
分类:
其他好文 时间:
2014-07-16 17:40:53
阅读次数:
192
- (void)viewDidLoad{ [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor];}
分类:
其他好文 时间:
2014-07-16 17:06:52
阅读次数:
163
UILabel *infoLabel = [[UILabel alloc]initWithFrame:CGRectMake(95, 20, 190, 70)]; infoLabel.backgroundColor = [UIColor clearColor]; infoLabel.textAl...
分类:
其他好文 时间:
2014-07-16 14:10:50
阅读次数:
162
经验:Template metaprogramming (TMP, 模板元编程)可将工作由运行期移往编译期,因而得以实现早期错误侦测和更高的执行效率
示例1:
template
void advance(IterT &iter, DistT d){
if(typeid(typename std::iterator_traits::iterator_catogory) == typeid(std::random_access_it...
分类:
编程语言 时间:
2014-07-16 13:20:54
阅读次数:
313