牛客多校(第九场 E题)

版权声明:本人是文盲,以上内容均看不懂是什么意思; 其次: 本次回帖之所有内容(包括但不限于汉字、拼音、外文字母、单词、句子、图片、影像、录音,以及前述之各种任意组合等等)完全是随机生成,本人并不明白其全部或部分之意思(包括但不限于对所生成之内容的识别、阅读、理解、分析、记忆等等),故本人不对以上及本内容负任何法律责任(包括但不限于刑事、民事责任)及其他潜在责任与义务。 https://blog.csdn.net/qq_37325947/article/details/81750831

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.
备注:
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
示例 1
输入
3 4
50 50 50
输出
750000020

代码写的我都不觉得能过,但是过了样例我就交了

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#define mem(a,x) memset(a,x,sizeof(a))
#define s1(x) scanf("%d",&x)
#define s2(x,y) scanf("%d%d",&x,&y)
#define s3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define s4(x,y,z,k) scanf("%d%d%d%d",&x,&y,&z,&k)
#define ff(a,n) for(int i = 0 ; i < n; i++) scanf("%d",a+i)
#define tp(x) printf("x = %d\n",x)
#define ansp(x) printf("%d\n",x)
//inline ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&(-x);return res;}
//inline void add(int x,int d){while(x<=n)c[x]+=d,x+=x&(-x);}
#define ls 2*rt
#define rs 2*rt+1
#define lson ls,L,mid
#define rson rs,mid+1,R
#define ll long long
using namespace std;
typedef pair<int,int> pii;
const ll inf = 0x3f3f3f3f;

const int mx = 1005;
const int mod = 1e9+7;
ll v,xm[mx];
int n,m,p[mx];
ll  powmod( ll a, ll b){
	ll ans = 1;
	a %= mod;
	while(b){
		if(b%2)
			ans=ans*a%mod;
		b/=2;
		a = a*a%mod;
	}
	return ans;
}
void init(){
	for(int i = 1; i <= 1000; i++)
		xm[i] = powmod(i,m);
}

int main(){
	//	freopen("F:\\in.txt","r",stdin);
	//int T=10;	scanf("%d",&T);

	s2(n,m);
	init();
	for(int i = 1; i <= n ;i++)
		scanf("%d",p+i);
	p[0] = p[n+1] = 0;
	ll ans = 0,te;
	for(int i = 1; i <= n ;i++){
		te = 1;
		for(int j = i; j <= n; j++){
			te *= p[j];
			if(te >= mod)
				te %= mod;
			ans += (100-p[i-1])*(100-p[j+1])*te%mod*powmod(100,1LL*(j-i+3)*(mod-2))%mod*xm[j-i+1]%mod;  //传入pow爆了int 
			if(ans >= mod)
				ans %= mod;
		}
 	}
 	cout<<ans<<endl; 


	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_37325947/article/details/81750831