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 81

The 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;//枚举哪一段是1
        for(int i=1;i<=n;i++)
        {
            dp[i][i-1]=1;//没选段的时候期望是1
            for(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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的精简博客系统,源码+数据库+毕业论文+视频演示 当下,正处于信息化的时代,许多行业顺应时代的变化,结合使用计算机技术向数字化、信息化建设迈进。以前企业对于博客信息的管理和控制,采用人工登记的方式保存相关数据,这种以人力为主的管理模式已然落后。本人结合使用主流的程序开发技术,设计了一款基于Springboot开发的精简博客系统,可以较大地减少人力、财力的损耗,方便相关人员及时更新和保存信息。本系统主要使用B/S开发模式,在idea开发平台上,运用Java语言设计相关的系统功能模块,MySQL数据库管理相关的系统数据信息,SpringBoot框架设计和开发系统功能架构,最后通过使用Tomcat服务器,在浏览器中发布设计的系统,并且完成系统与数据库的交互工作。本文对系统的需求分析、可行性分析、技术支持、功能设计、数据库设计、功能测试等内容做了较为详细的介绍,并且在本文中也展示了系统主要的功能模块设计界面和操作界面,并对其做出了必要的解释说明,方便用户对系统进行操作和使用,以及后期的相关人员对系统进行更新和维护。本系统的实现可以极大地提高企业的工作效率,提升用户的使用体验,因此在现实生活中运用本系统具有很大的使用价值。 关键词:博客管理;Java语言;B/S结构;MySQL数据库
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值