CodeForces 453A
Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.
The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, and so on, them-th face containsm dots.
Twilight Sparkle is sure that when the dice is tossed, each face appears with probability. Also she knows that each toss is independent
from others. Help her to calculate the expected maximum number of dots she could get after tossing the dicen times.
Input
A single line contains two integers m andn (1 ≤ m, n ≤ 105).
Output
Output a single real number corresponding to the expected maximum. The answer will be considered correct if its relative or absolute error doesn't exceed10 - 4.
Sample Input
6 1
3.500000000000
6 3
4.958333333333
2 2
1.750000000000
Hint
Consider the third test example. If you've made two tosses:
- You can get 1 in the first toss, and 2 in the second. Maximum equals to 2.
- You can get 1 in the first toss, and 1 in the second. Maximum equals to 1.
- You can get 2 in the first toss, and 1 in the second. Maximum equals to 2.
- You can get 2 in the first toss, and 2 in the second. Maximum equals to 2.
The probability of each outcome is 0.25, that is expectation equals to:
题目大意:
求出最大点数的期望(这两个字被平均取代后瞬间没有高尚感- -)。
思路:
若有5个的6面骰子出现最大点为1的次数为1^5,出现最大点为2的的次数为2^5-1^5,以此来推出最大点出现的次数为i^5-(i-1)^5;
求出最大值得期望,由演示样例能够得到 p = ( (1^n-0^n)*1 + (2^n-1^n)*2 。
。
。 +(m^n - (m-1)^n)*m ) / m^n ;将m^n带入
终于得到 p = m - ((m-1)/m)^n + ((m-2)/m)^n。
。。+(1/m)^n ;
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<algorithm>
#define LL long long
int a[1010];
using namespace std;
int main()
{
LL s;
int i,j,n,m,k,inr,x;
double sum;
while(scanf("%d%d",&m,&n)!=EOF)
{
sum=0;
for(i=1;i<=m;i++)
{
sum+=i*(pow(i*1.0/m,n)-pow((i-1)*1.0/m,n));<span id="transmark"></span>
}
printf("%.12lf\n",sum);
}
}
CodeForces 453A的更多相关文章
- CodeForces - 453A Little Pony and Expected Maximum
http://codeforces.com/problemset/problem/453/A 题目大意: 给定一个m面的筛子,求掷n次后,得到的最大的点数的期望 题解 设f[i]表示掷出 <= ...
- CodeForces 453A 概率题
Description Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter ...
- 嘴巴题9 Codeforces 453A. Little Pony and Expected Maximum
A. Little Pony and Expected Maximum time limit per test 1 second memory limit per test 256 megabytes ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- BZOJ 2780 Sevenk Love Oimaster (后缀自动机+树状数组+dfs序+离线)
题目大意: 给你$n$个大串和$m$个询问,每次给出一个字符串$s$询问在多少个大串中出现过 好神的一道题 对$n$个大串建出广义$SAM$,建出$parent$树 把字符串$s$放到$SAM$里跑, ...
- Vue引用第三方datepicker插件无法监听datepicker输入框的值
一.背景 在Vue项目中使用了第三方的datepicker插件,在选择日期后vue无法检测到datepicker输入框的变化 <label class="fl">日期: ...
- 论wpf的设备无关性 - 简书
原文:论wpf的设备无关性 - 简书 WPF从发布之日起,一直将“分辨率无关(resolution independence)”作为其亮点,声称使用WPF制作的用户界面在轻巧的Ultra-Mobile ...
- ASP.NET-HTML.Helper常用方法
Html.ActionLink方法 Html.ActionLink("linkText","actionName") Html.ActionLink(" ...
- javascript-js常用插件集合
area.js 中国地区分级的js代码 Scripts/crypto.js CryptoJS (crypto.js) 为 JavaScript 提供了各种各样的加密算法 ...
- nyoj 1189 yougth和他的朋友们 (DP)
题目:pid=1189" target="_blank">nyoj 1189 yougth和他的朋友们 这题目是14年北京赛区的原题.讲题的时候说有三种解法,我们是 ...
- lucene构建restful风格的简单搜索引擎服务
来自于本人博客: lucene构建restful风格的简单搜索引擎服务 本人的博客如今也要改成使用lucene进行全文检索的功能,因此在这里把代码贴出来与大家分享 一,文件夹结构: 二,配置文件: 总 ...
- Cocos2d-x-lua学习点滴
Lua下的方法.自己项目经验,个人见解,不能确保正确. Sprite: local Light = CCSprite:create("light.png") ...
- 蓝桥杯 - 带分数 (DFS)
历届试题 带分数 时间限制:1.0s 内存限制:256.0MB 问题描写叙述 100 能够表示为带分数的形式:100 = 3 + 69258 / 714. 还能够表示为:10 ...
- c# 获取文件夹下面所有文件夹列表
方法一: string dirPath = @"D:\App1"; List<string> dirs = new List<string>(Directo ...