编程介的小学生 2016-11-11 15:21 采纳率: 20.5%
浏览 806
已采纳

Door Repairing

Once upon a time, there was a famous university called Famous University. As thousands of students studied and lived in FU, a gigantic residential building was built, which is called ‘B37′. All students lived in B37 happily.

After decades, FU is still as famous as it had been in the past; however, the students living in it are now unhappy, because B37 is too old. Although the door of the building looks fine, it can be easily broken when being opened by some careless student too forcefully.

So, YY, the accommodation officer of B37, is facing an extremely serious problem.

With some mysterious methods, YY has predicted that exactly N students will enter or exit B37 during the next term. Unfortunately he doesn’t know who the careless ones are, so he assumes that every student opening the door has a probability of P percent to be a careless one. When the door is broken by some careless guy, YY may repair it immediately or after some time, with a cost of A yuan. Unfortunately when a student goes through the door and finds it already broken and not repaired, he will report it to the headmaster, and YY will be subject to a fine of B yuan. The door is in good condition before the term begins, and will be repaired by the university after the term ends, so YY can leave the door unrepaired at the end of the term.

Being good at mathematics, YY has made a strategy, to decide when to and when not to repair the door, in order to minimize his expense.

Please write a program to calculate the expectation of his expense.

输入:

The input consists of multiple test cases.

For each test case, there is one line containing four non-negative integers N, P, A, B described as above, with 0<=N<=100000, 0<=P<=100, 0<=A<=100, 0<=B<=100.

End of input is indicated by a line consisting of four zeros.

输出:

The input consists of multiple test cases.

For each test case, there is one line containing four non-negative integers N, P, A, B described as above, with 0<=N<=100000, 0<=P<=100, 0<=A<=100, 0<=B<=100.

End of input is indicated by a line consisting of four zeros.

样例输入:

10 100 0 1
10 100 1 0
2 50 2 1
0 0 0 0
样例输出:

0.0000
0.0000
0.5000

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-11-11 15:21
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序