题目链接:

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 ;
}

最新文章

  1. ASP.NET Core 中文文档 第三章 原理(4)路由
  2. MMORPG大型游戏设计与开发(服务器 游戏场景 地图和区域)
  3. Asp.Net HttpContext.RemapHandler 用法
  4. spark streaming 接收 kafka 数据java代码WordCount示例
  5. 【leetcode】Spiral Matrix
  6. C#中获得机器的字符编码webName信息
  7. 【设计模式】常用de单例模式
  8. silverlight 鼠标事件处理
  9. Robot Framework-DatabaseLibrary数据库(MySql)
  10. C# 窗体间传值方法大汇总
  11. cpoint
  12. C语言第二次博客作业—分支结构
  13. 顺序栈代码实现&amp;&amp;stack库
  14. 使用trash-cli防止rm -rf 误删除带来的灾难(“事前”非“事后”)
  15. Kendo ui 入门知识点
  16. NOIP训练测试2(2017081502)
  17. 3-29 params的理解; Active Model Errors; PolymorphicRoutes 多态的路径; ::Routing::UrlFor
  18. 排序算法(2) 堆排序 C++实现
  19. 单点登录(九)-----遇到问题-----FileNotFoundException: class path resource-UsernamePasswordWrapperAuthenticatio
  20. win7下hadoop编程eclipse的配置

热门文章

  1. oracle 用户被锁定解锁方法
  2. 嵌入式(Embedded System)笔记 —— Cortex-M3 Introduction and Basics(上)
  3. 问题:JFinal框架使用FreeMarker渲染视图报错
  4. android SharedPreferences 浅析
  5. 项目中DataTables分页插件的使用
  6. 课时2:用python设计第一个游戏
  7. C# MemoryCache 类[转载]
  8. HDU 4655 Cut Pieces 找规律+简单计数
  9. python鉴黄程序
  10. 【Linux】- 获取root权限命令