Codeforces Round #259 (Div. 1) A. Little Pony and Expected Maximum 数学公式结论找规律水题
A. Little Pony and Expected Maximum
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/453/problem/A
Description
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, the m-th face contains m 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 dice n times.
Input
A single line contains two integers m and n (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 exceed 10 - 4.
Sample Input
6 1
Sample Output
HINT
题意
给你一个m面的筛子,然后扔N次,求最大值的期望是多少
题解:
一开始还以为是个概率dp,哎
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/*
inline ll read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int buf[10];
inline void write(int i) {
int p = 0;if(i == 0) p++;
else while(i) {buf[p++] = i % 10;i /= 10;}
for(int j = p-1; j >=0; j--) putchar('0' + buf[j]);
printf("\n");
}
*/
//************************************************************************************** int main()
{
int m,n;
cin>>m>>n;
double pre=;
double ans=;
for(int i=;i<=m;i++)
{
double now=pow((double(i)/double(m)),double(n));
//cout<<now<<endl;
ans+=(now-pre)*i;
pre=now;
}
printf("%.10f\n",ans);
}
Codeforces Round #259 (Div. 1) A. Little Pony and Expected Maximum 数学公式结论找规律水题的更多相关文章
- Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum (数学期望)
题目链接 题意 : 一个m面的骰子,掷n次,问得到最大值的期望. 思路 : 数学期望,离散时的公式是E(X) = X1*p(X1) + X2*p(X2) + …… + Xn*p(Xn) p(xi)的是 ...
- Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum
题目链接 题意:一个m个面的骰子,抛掷n次,求这n次里最大值的期望是多少.(看样例就知道) 分析: m个面抛n次的总的情况是m^n, 开始m==1时,只有一种 现在增加m = 2, 则这些情况是新增 ...
- Codeforces Round #259 (Div. 2) D. Little Pony and Harmony Chest 状压DP
D. Little Pony and Harmony Chest Princess Twilight went to Celestia and Luna's old castle to resea ...
- Codeforces Round #259 (Div. 2)-D. Little Pony and Harmony Chest
题目范围给的很小,所以有状压的方向. 我们是构造出一个数列,且数列中每两个数的最大公约数为1; 给的A[I]<=30,这是一个突破点. 可以发现B[I]中的数不会很大,要不然就不满足,所以B[I ...
- Codeforces Round #259 (Div. 2)
A. Little Pony and Crystal Mine 水题,每行D的个数为1,3.......n-2,n,n-2,.....3,1,然后打印即可 #include <iostream& ...
- Codeforces Round #259 (Div. 2)AB
链接:http://codeforces.com/contest/454/problem/A A. Little Pony and Crystal Mine time limit per test 1 ...
- Codeforces Round #259 (Div. 2) D
D. Little Pony and Harmony Chest time limit per test 4 seconds memory limit per test 256 megabytes i ...
- Codeforces Round #259 (Div. 1)A(公式)
传送门 题意 给出m个面的骰子扔n次,取最大值,求期望 分析 暴力算会有重复,而且复杂度不对. 考虑m个面扔n次得到m的概率,发现只要减去(m-1)个面扔n次得到m-1的概率即可,给出example说 ...
- Codeforces Round #563 (Div. 2) E. Ehab and the Expected GCD Problem
https://codeforces.com/contest/1174/problem/E dp 好题 *(if 满足条件) 满足条件 *1 不满足条件 *0 ///这代码虽然写着方便,但是常数有点大 ...
随机推荐
- AngularJS中ng-class使用方法
转自:https://blog.csdn.net/jumtre/article/details/50802136 其他博文ng-class使用方法:https://blog.csdn.net/sina ...
- hibernate的枚举注解@Enumerated
@Enumerated(value=EnumType.ORDINAL)采用枚举类型的序号值与数据库进行交互, 此时数据库的数据类型需要是数值类型,例如在实际操作中 CatTest ct = new C ...
- 试用Redis
Windows 10家庭中文版,运行于VirtualBox上的Ubuntu 18.04,Redis 4.0.10, Redis,久仰大名!因为没有从事互联网行业,所以一直没有使用过.近期找工作,也隐约 ...
- 数据库--mysql介绍
一:什么是数据库 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库, 每个数据库都有一个或多个不同的API用于创建,访问,管理,搜索和复制所保存的数据. 我们也可以将数据存储在文件 ...
- [java笔记]常用的设计模式
1.单例设计模式 单例设计模式:保证一个类仅有一个实例,并提供一个访问它的全局访问点. 1)构造方法私有化 2)声明一个本类对象 3)给外部提供一个静态方法获取对象实例 例如: class Singl ...
- C++ 实现memcpy和strcpy
/** * @Method: Memcpy * @Access: public * @Return: void * * @Param : dst - 目的起始地址 * @Param : src - 源 ...
- Flask 对象关系
建立一个关系 from sqlalchemy import Column, Integer, String, MetaData, ForeignKey from sqlalchemy.ext.decl ...
- js中的Object.seal()与Object.freeze()
关键字:seal, freeze, property descriptor. 1.Object.seal() 参考文档(2)中这样描述: The Object.seal() method seals ...
- Spark(八)JVM调优以及GC垃圾收集器
一JVM结构 1 Java内存结构 JVM内存结构主要有三大块:堆内存.方法区和栈. 堆内存是JVM中最大的一块由年轻代和老年代组成,而年轻代内存又被分成三部分,Eden空间.From Survivo ...
- C语言:九九乘法表打印
题目: 要求:用“,”分隔算式,用“:”做一行的结尾. 另外1*1=1:这个算式是程序的第一行,前面没有空行. 文字版如下: 输入格式: 无 输出格式: 1*1=1; 2*1=2,2*2=4; 3*1 ...