hdu 5159(概率)
2024-09-01 03:22:03
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5159
题解:假设在 x 张牌中选b张牌,那么有 x^b 种选法,如果在 (x-1) 张牌中选 b 张牌,那么有 (x-1)^b 种选法,所以第 i 张牌出现的概率是 (x^b-(x-1)^b)/x^b 再对每张牌乘上牌面的值即是期望.
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
#include <queue>
using namespace std;
typedef unsigned long long LL;
int main()
{
int tcase;
scanf("%d",&tcase);
int t =;
while(tcase--){
int x,b;
scanf("%d%d",&x,&b);
double a = -pow(-1.0/x,b);
printf("Case #%d: %.3lf\n",t++,a*(x+)*x/);
}
return ;
}
最新文章
- ASP.NET Core 中文文档 第三章 原理(4)路由
- MMORPG大型游戏设计与开发(服务器 游戏场景 地图和区域)
- Asp.Net HttpContext.RemapHandler 用法
- spark streaming 接收 kafka 数据java代码WordCount示例
- 【leetcode】Spiral Matrix
- C#中获得机器的字符编码webName信息
- 【设计模式】常用de单例模式
- silverlight 鼠标事件处理
- Robot Framework-DatabaseLibrary数据库(MySql)
- C# 窗体间传值方法大汇总
- cpoint
- C语言第二次博客作业—分支结构
- 顺序栈代码实现&;&;stack库
- 使用trash-cli防止rm -rf 误删除带来的灾难(“事前”非“事后”)
- Kendo ui 入门知识点
- NOIP训练测试2(2017081502)
- 3-29 params的理解; Active Model Errors; PolymorphicRoutes 多态的路径; ::Routing::UrlFor
- 排序算法(2) 堆排序 C++实现
- 单点登录(九)-----遇到问题-----FileNotFoundException: class path resource-UsernamePasswordWrapperAuthenticatio
- win7下hadoop编程eclipse的配置