Throwing Balls into the Baskets LightOJ - 1317
2017-10-09 19:31
281 查看
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 N people 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). P contains 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
Think:与篮子无关,最终结果都是要投进去,直接求
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). P contains 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
Think:与篮子无关,最终结果都是要投进去,直接求
#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> using namespace std; int main(){ double n,m,k,p; int t; int tt=1; scanf("%d",&t); while(t--){ scanf("%lf%lf%lf%lf",&n,&m,&k,&p); double sum=n*k*p; printf("Case %d: %.10f\n",tt++,sum); } return 0; }
相关文章推荐
- lightoj 1317 Throwing Balls into the Baskets
- lightOJ 1317 - Throwing Balls into the Baskets
- LightOJ 1317 Throwing Balls into the Baskets
- LightOJ - 1317 Throwing Balls into the Baskets 期望
- LightOJ 1317 - Throwing Balls into the Baskets
- LightOJ - 1317 Throwing Balls into the Baskets 期望
- LightOJ1317---Throwing Balls into the Baskets (概率dp)
- lightOJ 1317 Throwing Balls into the Baskets
- Throwing Balls into the Baskets LightOJ - 1317 (巨水水题)
- Light OJ 1317 Throwing Balls into the Baskets 概率DP
- Light OJ 1317 Throwing Balls into the Baskets 概率DP
- Throwing Balls into the Baskets (概率)
- LightOJ1317-Throwing Balls into the Baskets
- Book Review of Dynamics of Software Development--Get their heads into the game
- Aion Quest: Go Back into the Frillneck Habitat
- To compile Boost.Python yourself download boost from boost.org and then go into the boost root fold
- Unity3d 打包时报错 CommandInvokationFailure: Unable to convert classes into dex format. See the Console f
- How to use .NET Windows Control into the WPF Application
- LightOJ 1025 - The Specials Menu(区间DP)