light oj 1317
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 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
#include<cstdio>
using namespace std;
int main()
{
int T;
int casex=1;
double N,M,K,P;
double ans;
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf",&N,&M,&K,&P);
ans=N*K*P;
printf("Case %d: %lf\n",casex++,ans);
}
return 0;
}
light oj 1317的更多相关文章
- Light OJ 1317 Throwing Balls into the Baskets 概率DP
n个人 m个篮子 每一轮每一个人能够选m个篮子中一个扔球 扔中的概率都是p 求k轮后全部篮子里面球数量的期望值 依据全期望公式 进行一轮球数量的期望值为dp[1]*1+dp[2]*2+...+dp[ ...
- Light OJ 1114 Easily Readable 字典树
题目来源:Light OJ 1114 Easily Readable 题意:求一个句子有多少种组成方案 仅仅要满足每一个单词的首尾字符一样 中间顺序能够变化 思路:每一个单词除了首尾 中间的字符排序 ...
- Light OJ 1429 Assassin`s Creed (II) BFS+缩点+最小路径覆盖
题目来源:Light OJ 1429 Assassin`s Creed (II) 题意:最少几个人走全然图 能够反复走 有向图 思路:假设是DAG图而且每一个点不能反复走 那么就是裸的最小路径覆盖 如 ...
- Light OJ 1406 Assassin`s Creed 减少国家DP+支撑点甚至通缩+最小路径覆盖
标题来源:problem=1406">Light OJ 1406 Assassin`s Creed 意甲冠军:向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路: ...
- Light OJ 1316 A Wedding Party 最短路+状态压缩DP
题目来源:Light OJ 1316 1316 - A Wedding Party 题意:和HDU 4284 差点儿相同 有一些商店 从起点到终点在走过尽量多商店的情况下求最短路 思路:首先预处理每两 ...
- light oj 1007 Mathematically Hard (欧拉函数)
题目地址:light oj 1007 第一发欧拉函数. 欧拉函数重要性质: 设a为N的质因数.若(N % a == 0 && (N / a) % a == 0) 则有E(N)=E(N ...
- Light OJ 1406 Assassin`s Creed 状态压缩DP+强连通缩点+最小路径覆盖
题目来源:Light OJ 1406 Assassin`s Creed 题意:有向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路:最少的的人能够走全然图 明显是最小路径覆盖问题 ...
- Light OJ 1288 Subsets Forming Perfect Squares 高斯消元求矩阵的秩
题目来源:Light OJ 1288 Subsets Forming Perfect Squares 题意:给你n个数 选出一些数 他们的乘积是全然平方数 求有多少种方案 思路:每一个数分解因子 每隔 ...
- Jan's light oj 01--二分搜索篇
碰到的一般题型:1.准确值二分查找,或者三分查找(类似二次函数的模型). 2.与计算几何相结合答案精度要求比较高的二分查找,有时与圆有关系时需要用到反三角函数利用 角度解题. 3.不好直接求解的一类计 ...
随机推荐
- js如何实现php的in_array()
var arr = [ 4, "Pete", 8, "John" ]; jQuery.inArray("John", arr); //3 j ...
- 【codeforces 734F】Anton and School
[题目链接]:http://codeforces.com/problemset/problem/734/F [题意] 给你两个数组b和c; 然后让你找出一个非负数组a满足题中所给关系; [题解] 有个 ...
- sigprocmask和信号阻塞
注意阻塞和忽略,是有区别的. 阻塞只是暂时的,忽略是就没了. 参数:how:用于指定信号修改的方式,可能选择有三种:SIG_BLOCK //加入信号到进程屏蔽.SIG_UNBLOCK //从进程屏蔽里 ...
- objective-c訪问控制符
objective-c中成员变量的四个訪问控制符: @private:仅仅有当前类的内部才干訪问 @public:全部人都可訪问 @protected:仅仅限当前类和它的子类可以訪问 @package ...
- leetcode第一刷_Reverse Linked List II
翻转链表绝对是终点项目,应该掌握的,这道题要求的是翻转一个区间内的节点.做法事实上非常相似,仅仅只是要注意判定開始是头的特殊情况,这样head要更新的,还有就是要把翻转之后的尾部下一个节点保存好,要么 ...
- PHP静态延迟绑定简单演示样例
没怎么用过这个新特性.事实上也不算新啦,试试吧,如今静态类的继承非常方便了 <?php class A { protected static $def = '123456'; public st ...
- linux 命令 xxd
xxd,能够查看linux下文件的二进制表示.man一下xxd.能够得到下面信息 NAME xxd - make a hexdump or do the reverse. SYNOPSI ...
- Hibernate的xml方法配置和操作代码
一.gradle中包: compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.12.Final' compile ...
- 2)Win10-UWA开发 API參考 - 1
孙广东 2015.8.23 大多数 Windows 执行时 API 如今适用于 Windows Phone 应用商店应用以及 Windows 应用商店应用,这意味着当你创建同一时候面向 Window ...
- UVA 1016 - Silly Sort 置换分解 贪心
Silly Sort Your younger brother has an assignment and needs s ...