首页 > ACM题库 > HDU-杭电 > HDU 3210-Another Door Repairing Problem-待解决[解题报告]HOJ
2014
03-06

HDU 3210-Another Door Repairing Problem-待解决[解题报告]HOJ

Another Door Repairing Problem

问题描述 :

Maybe you have already solved the Door Repairing Problem for YY, who is the officer of the accommodation building B37, in a famous university called Famous University. Maybe you have not, but it does not matter because the new term is coming. So here comes the Another Door Repairing Problem!As is described in Door Repairing Problem, many students live in B37. The building is old, so sometimes a careless student such as LMY may open the door of the building too vigorously, and break it as a result. However, when a student opens the door and finds it already broken, he will report it to the headmaster, and YY will be punished as a result…

More precisely, the door is fine at the beginning of the term. The term has a length of Tterm. During the term, the door will be opened many times, which can be regarded as a Poisson process, i.e., in any period of length T, the probability that the door will be opened k times isJumping Hands, where λ is a positive real constant.

Note that for any non-negative real T, Jumping Hands
When the door is fine and is opened by some student, the probability that he carelessly breaks the door is p. (0<p<=1) When the door is broken, YY can repair it anytime he likes.

Both repairing the door and being punished cost a lot. YY has thought for many days trying to make a best strategy when to repair the door, so that his expense can be minimized in expectation. He failed, so he is going to try the simplest ways. Given the length of the term Tterm, the constant λ, the probability p, and the question type Q, you are to solve the Another Door Repairing Problem:

When Q=1, tell the expected number of times YY has to repair the door, if he always repairs it immediately after it is broken.

When Q=2, tell the expected number of times YY will be punished, if he never repairs the door.

输入:

Input contains multiple test cases.A test case consists of a single line containing four numbers. The first is an integer Q, where Q=1 or Q=2 holds, indicating the type of the problem that you should solve. Three positive real numbers λ, Tterm and p follow. The real numbers may be given in fixed-point or scientific e notations. All real numbers can be store in a double data type of C/C++, with a sufficiently small error rate. See the sample input for details.

Input ends with a line containing four space-separated 0s.

输出:

Input contains multiple test cases.A test case consists of a single line containing four numbers. The first is an integer Q, where Q=1 or Q=2 holds, indicating the type of the problem that you should solve. Three positive real numbers λ, Tterm and p follow. The real numbers may be given in fixed-point or scientific e notations. All real numbers can be store in a double data type of C/C++, with a sufficiently small error rate. See the sample input for details.

Input ends with a line containing four space-separated 0s.

样例输入:

1 1 1 0.5
1 1 1 1e0
2 1 1 5.00000e-0001
0 0 0 0

样例输出:

5.00 -1
1.00 0
2.13 -1
Hint

The solution to sample input is 0.5, 1.0 and 0.213, respectively. Don’t worry about inputting real numbers in scientific e notations. A simple scanf or cin as if it is fixed-point is OK.

 


  1. #include <stdio.h>
    int main(void)
    {
    int arr[] = {10,20,30,40,50,60};
    int *p=arr;
    printf("%d,%d,",*p++,*++p);
    printf("%d,%d,%d",*p,*p++,*++p);
    return 0;
    }

    为什么是 20,20,50,40,50. 我觉得的应该是 20,20,40,40,50 . 谁能解释下?

  2. Thanks for using the time to examine this, I truly feel strongly about it and enjoy finding out far more on this subject matter. If achievable, as you achieve knowledge

  3. 问题3是不是应该为1/4 .因为截取的三段,无论是否能组成三角形, x, y-x ,1-y,都应大于0,所以 x<y,基础应该是一个大三角形。小三角是大三角的 1/4.