Music Game
链接:https://www.nowcoder.com/acm/contest/147/E
来源:牛客网
Music Game
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
Niuniu likes to play OSU!
We simplify the game OSU to the following problem.
Given n and m, there are n clicks. Each click may success or fail.
For a continuous success sequence with length X, the player can score X^m.
The probability that the i-th click success is p[i]/100.
We want to know the expectation of score.
As the result might be very large (and not integral), you only need to output the result mod 1000000007.
输入描述:
The first line contains two integers, which are n and m. The second line contains n integers. The i-th integer is p[i].1 <= n <= 1000 1 <= m <= 1000 0 <= p[i] <= 100
输出描述:
You should output an integer, which is the answer.
示例1
输入
复制
3 4 50 50 50
输出
复制
750000020
说明
000 0 001 1 010 1 011 16 100 1 101 2 110 16 111 81The exact answer is (0 + 1 + 1 + 16 + 1 + 2 + 16 + 81) / 8 = 59/4. As 750000020 * 4 mod 1000000007 = 59 You should output 750000020.
备注:
If you don't know how to output a fraction mod 1000000007, You may have a look at https://en.wikipedia.org/wiki/Modular_multiplicative_inverse
分析:第i次点击时的长度,设第i-1次点击时的长度x
len=(1-pi)*0+pi(x+1)
第i次点击时的得分,dp[i]=(1-pi)*0+pi*(x+1)^m
=pi*(C(m,0)*x^m+C(m,1)*x^(m-1)+···+C(m,m-1)*x^(m-(m-1))+C(m,m)*x^(m-m))
=pi*(dp[i-1]+C(m,1)*x^(m-1)+···+C(m,m-1)*x^(m-(m-1))+C(m,m)*x^(m-m)
所以需要维护x^(m-1)···x好难,不懂
所以暴力YY了
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1010;
const ll mo=1e9+7;
ll n,m,k;
ll a[maxn],dp[maxn][maxn],sum[maxn][maxn];
ll c[maxn];
ll ans,ct,cnt,tmp,flag;
ll power(ll a,ll n) //a的n次方mod
{ll ans=1;a=a%mo;while (n){if(n&1) ans=(ans*a)%mo;n>>=1;a=(a*a)%mo;}return ans;
}
int main()
{int T,cas=1;while(scanf("%lld %lld",&n,&m)!=EOF){c[1]=1;for(int i=2;i<=1000;i++) c[i]=power(i,m);ans=0;tmp=power(100,mo-2);for(int i=1;i<=n;i++){scanf("%lld",&a[i]);}a[0]=a[n+1]=0;//枚举哪一段是1for(int i=1;i<=n;i++){dp[i][i-1]=1;//没选段的时候期望是1for(int j=i;j<=n;j++){dp[i][j]=dp[i][j-1]*a[j]%mo*tmp%mo;ans=(ans+dp[i][j]*(100-a[i-1])%mo*tmp%mo*(100-a[j+1])%mo*tmp%mo*c[j-i+1]%mo)%mo;//[i,j]是1必须保证前一个后一个都是0,不然就不是[i,j]是1,就比[i,j]大了}}ans=(ans+mo)%mo;printf("%lld\n",ans);// if(flag) puts("Yes"); else puts("No");}return 0;
}
最新文章
- 论文作者串通抱团、威胁审稿人,ACM Fellow炮轰「同行评审」作弊
- 【天池直播--预告】美女程序猿带你用大数据吃鸡(有内涵-这是一个有大奖的活动)...
- Exercise: Logistic Regression and Newton's Method
- 【python】sys.stdout输出不换行
- delphi 登录界面 主窗体 切换_.NET CORE(C#) WPF 方便的实现用户控件切换(祝大家新年快乐)
- BasicExcel CSpreadSheet 使用感受
- ArcMap 导入 wrl_ai文件导入c4d没反应怎么办? c4d导入ai源文件失败的原因分析_Illustrator教程_平面设计...
- xmind怎样画流程图_老师是怎样上网课的?
- Vue的调试工具(Chrome 浏览器)配置
- 计算机睡眠之后无法唤醒,电脑进入睡眠状态后无法唤醒一直黑屏,该如何处理...
- matlab最基础教程(四):常用的系统自带函数,符号变量与字符串篇
- Yolov5图像识别教程
- Python入门经典笔记之安装numpy和matplotlib遇到的问题
- 02 学生成绩表(C语言)
- 夏普linux电视软件,夏普电视第三方软件安装方法,使用教程和攻略
- 自己动手写股票数据分析软件之数据获取
- 数据中台开源解决方案(一)
- 美团点评2020校招笔试 2019.08.22
- Intent之对象传递(Parcelable传递对象和对象集合)
- Witt向量简介 §3.2.2:Witt环运算封闭性验证
热门文章
- python 菜鸟-Python IDE
- python100例详解-Python编程之属性和方法实例详解
- 学python有前途吗-学python有前途吗?
- 树莓派百度语音识别+图灵机器人对话聊天机器人
- python用户画像_新闻个性化推荐系统源码之构建离线用户和文章特征
- 我的世界服务器氪金系统怎么做,[经济]PPRMB销售系统 1.3.1 —— 地图扫码自动到账,氪金系统如此简单[全版本]...
- 【狂神MySQL笔记】常用命令行语句(1)
- 【深度优先搜索】网格类问题:牛客网:机器人的运动范围
- python非法变量名_python – DatabaseError:ORA-01036:非法变量名称/编号
- linux开启和关闭防火墙