Problem Description   You live in a village but work in another village. You decided to follow the straight path between your house (A) and the working place (B), but there are several rivers you need to cross. Assume B is to the right of A, and all…
题意:你要从A到B去上班,然而这中间有n条河,距离为d.给定这n条河离A的距离p,长度L,和船的移动速度v,求从A到B的时间的数学期望. 并且假设出门前每条船的位置是随机的,如果不是在端点,方向也是不定的,你在陆地行走速度为1,输入保证河在AB之前,并且不会重叠. 析:一看这个题,好像不会啊...这怎么求,这么乱,这么复杂... 但是仔细一想求时间期望,不就是在过河的地方时间不是固定的么,只要求出过河的时间的数学期望,利用数学期望的线性,加起来就OK了. 这样一想感觉就不乱了,那么怎么求每个河的…
题意:你在点A,目的地是点B,A和B的距离为D.中间隔了好多条河(所有河不会重叠),每条河有3个参数(P,L,V),其中P表示距离A点的长度,L表示河的长度,V表示河里的船的速度.假设每条河中仅有1条自动船,以速度V左右匀速运动,碰到河的端点就反向走.那么从A点到B点的期望是多沙? 注意:A点到B点都是在x轴上,而任意河只是[A,B]中的一个子区间而已,只是所有子区间都不会重叠. 思路:刚开始以为会有河可能是重叠的,想了N久. 由于船的任意时刻的位置都是随机的,那就是概率相等的,那么当走到该河的…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3382 题意: 你住在村庄A,每天需要过很多条河到另一个村庄B上班.B在A的右边,所有的河都在中间.幸运的是,每条河上都有匀速移动的自动船,因此每当到达一条河的左岸时,只需等船过来,载着你过河,然后在右岸下船.你很瘦,因此上船之后船速不变.日复一日,年复一年,你问自己:从A到B,平均…
Description Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a new program, he classifies all possible bugs into n categories. Each day he discovers exac…
Hard problem 题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5858 Description cjj is fun with math problem. One day he found a Olympic Mathematics problem for primary school students. It is too difficult for cjj. Can you solve it? Give you the…
题目链接 /* 到达一条河时,船在河中的位置是随机的,所以船到达岸边需要的时间在 0~2l/v 均匀分布,所以船到岸的期望为 (0+2l/v)/2 过河需要 l/v 的时间,所以过一条河总的期望为 (0+2l/v)/2 + l/v = 2l/v 陆地上的速度是确定的,可以直接先计算出来 期望是线性的,每条河期望相加即为过河的总期望 */ #include<cstdio> using namespace std; int main() { int n,d,p,l,v,cas=0; while(~…
Problem Description A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog ,,⋯ from the bottom, so are the columns. At first the frog is sitting at grid (sx,sy), and begins his journey. To show…
题意:给出一个偶数(不论正负),求出两个素数a,b,能够满足 a-b=x,素数在1e6以内. 只要用筛选法打出素数表,枚举查询下就行了. 我用set储存素数,然后遍历set里面的元素,查询+x后是否还是素数. 注意,偶数有可能是负数,其实负数就是将它正数时的结果颠倒就行了. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * Blog: http://blog.csdn.net/hcbbt * File: 10.cpp * Create Date:…
Zhuge Liang's Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 59    Accepted Submission(s): 47 Problem Description In the ancient three kingdom period, Zhuge Liang was the most famous a…