LightOJ 1317 第六周比赛A题
2015-08-21 20:21
225 查看
A - A
Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Description
You probably have played the game "Throwing Balls into the Basket". It is a simple game. You have to throw a ball into a basket from a certain distance. One day we (the AIUB ACMMER) were playing the game. But it was slightly different from the main game. In our game we were Npeople trying to throw balls into M identical Baskets. At each turn we all were selecting a basket and trying to throw a ball into it. After the game we saw exactly S balls were successful. Now you will be given the value of N and M. For each player probability of throwing a ball into any basket successfully is P. Assume that there are infinitely many balls and the probability of choosing a basket by any player is 1/M. If multiple people choose a common basket and throw their ball, you can assume that their balls will not conflict, and the probability remains same for getting inside a basket. You have to find the expected number of balls entered into the baskets after K turns.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing three integers N (1 ≤ N ≤ 16), M (1 ≤ M ≤ 100) and K (0 ≤ K ≤ 100) and a real number P (0 ≤ P ≤ 1). Pcontains at most three places after the decimal point.
Output
For each case, print the case number and the expected number of balls. Errors less than 10-6 will be ignored.
Sample Input
2
1 1 1 0.5
1 1 2 0.5
Sample Output
Case 1: 0.5
Case 2: 1.000000
题解:有N个人M个篮筐每个人投进篮筐的概率是P,可以投K轮,求投进去的球。
其实就是求期望值,为什么呢?因为输出的的答案都是小数,所以肯定不是投进去的球数
Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Description
You probably have played the game "Throwing Balls into the Basket". It is a simple game. You have to throw a ball into a basket from a certain distance. One day we (the AIUB ACMMER) were playing the game. But it was slightly different from the main game. In our game we were Npeople trying to throw balls into M identical Baskets. At each turn we all were selecting a basket and trying to throw a ball into it. After the game we saw exactly S balls were successful. Now you will be given the value of N and M. For each player probability of throwing a ball into any basket successfully is P. Assume that there are infinitely many balls and the probability of choosing a basket by any player is 1/M. If multiple people choose a common basket and throw their ball, you can assume that their balls will not conflict, and the probability remains same for getting inside a basket. You have to find the expected number of balls entered into the baskets after K turns.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing three integers N (1 ≤ N ≤ 16), M (1 ≤ M ≤ 100) and K (0 ≤ K ≤ 100) and a real number P (0 ≤ P ≤ 1). Pcontains at most three places after the decimal point.
Output
For each case, print the case number and the expected number of balls. Errors less than 10-6 will be ignored.
Sample Input
2
1 1 1 0.5
1 1 2 0.5
Sample Output
Case 1: 0.5
Case 2: 1.000000
题解:有N个人M个篮筐每个人投进篮筐的概率是P,可以投K轮,求投进去的球。
其实就是求期望值,为什么呢?因为输出的的答案都是小数,所以肯定不是投进去的球数
#include<iostream> #include<cstdio> using namespace std; int main() { int t,n,m,k,ca=1; double p; cin>>t; while(t--) { cin>>n>>m>>k>>p; printf("Case %d: %.6lf\n",ca++, k*n*p); } }
相关文章推荐
- jQuery学习笔记(二)
- 【c++版数据结构】之双链表的实现(带头结点以及尾节点)
- C/C++易错难点笔记01
- 归档与解归档
- js事件
- PAAS平台7×24小时可用性应用设计
- lightoj 1079 Just another Robbery 解题心得
- FZUOJ 2135 数字游戏
- 深入理解JavaScript系列(33):设计模式之策略模式
- 各种排序算法的稳定性和时间复杂度小结
- LLVM基金会获得 501(c)(3) 非营利身份
- Ubuntu系统进程绑定CPU核
- 09-散列1. Hashing (25) -- 读题仔细
- treap 排序二叉树的模板
- 常用委托方法
- Hdu oj 2066 一个人的旅行
- git学习——<五>git分支
- 深入理解JavaScript系列(32):设计模式之观察者模式
- RAFT algorithm
- win7 vmware 装的64位 ubuntu 没有声音解决办法