UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213344#2053. 地雷爆炸nullptr_qwq1006ms1260kbC++116.0kb2024-11-11 18:38:212024-11-11 23:01:23

answer

// 私は猫です

#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define int long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define inf 1000000000
#define infll 1000000000000000000ll
#define pii pair<int,int>
#define rep(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define per(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define dF(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define cmh(sjy) while(sjy--)
#define lowbit(x) (x&(-x))
#define HH printf("\n")
#define eb emplace_back
#define poly vector<int>
#define SZ(x) ((int)x.size())
using namespace std;
ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*f;
}
namespace Fastio{struct Reader{template<typename T>Reader&operator>>(T&x){x=0;short f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();x*=f;return*this;}Reader&operator>>(double&x){x=0;double t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(long double&x){x=0;long double t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(__float128&x){x=0;__float128 t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(char&c){c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();return*this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();while(c!=' '&&c!='\n'&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(string&str){str.clear();char c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();while(c!=' '&&c!='\n'&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{const int Setprecision=6;typedef int mxdouble;template<typename T>Writer&operator<<(T x){if(x==0){putchar('0');return*this;}if(x<0)putchar('-'),x=-x;static short sta[40];short top=0;while(x>0)sta[++top]=x%10,x/=10;while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(double x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(double)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(long double x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(long double)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(__float128 x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(__float128)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(char c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}using namespace Fastio;
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
template<typename T>inline void chkmax(T &x,const T &y){ x=std::max(x,y); }
template<typename T>inline void chkmin(T &x,const T &y){ x=std::min(x,y); }
const int mod=998244353,maxn=500005;
inline int qpow(int x,ll y){
	int rt=1;
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) rt=1ll*rt*x%mod;
	return rt;
}
inline void inc(int &x,const int y){ x=(x+y>=mod)?(x+y-mod):(x+y); }
inline void dec(int &x,const int y){ x=(x>=y)?(x-y):(x+mod-y); }
inline void mul(int &x,const int y){ x=1ll*x*y%mod; }
inline int add(const int x,const int y){ return (x+y>=mod)?(x+y-mod):(x+y); }
inline int sub(const int x,const int y){ return (x>=y)?(x-y):(x+mod-y); }
inline int prod(const int x,const int y){ return 1ll*x*y%mod; }
inline int mypow(int x,int y,int Mod){
	x%=Mod; int rt=1;
	for(;y;y>>=1,x=(1ll*x*x)%Mod) if(y&1) rt=(1ll*rt*x)%Mod;
	return rt;
}
mt19937 eng(std::chrono::steady_clock::now().time_since_epoch().count());
inline int rd(const int l,const int r) { return std::uniform_int_distribution<int>(l,r)(eng); }
namespace combi{
	int fac[maxn],ifac[maxn],inv[maxn];
	void init(const int N){
		fac[0]=ifac[0]=inv[0]=1;
		F(i,1,N) fac[i]=1ll*fac[i-1]*i%mod;
		ifac[N]=qpow(fac[N],mod-2);
		dF(i,N-1,1) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
		F(i,1,N) inv[i]=1ll*ifac[i]*fac[i-1]%mod;
	}
	inline int C(const int n,const int m){
		if(m>n||n<0||m<0) return 0;
		return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
	}
}
//using namespace combi;
double p[1005],f[1005];
int n,m;
void solve(){
	cin>>n>>m;
	F(i,1,n)cin>>p[i];
	f[1]=p[1];
	F(i,2,m)F(j,1,n)f[i]+=p[j]*pow(f[i-1],j-1);
	printf("%.4lf",f[m]);
}
signed main(){
	int zsy=1;
	F(____,1,zsy)solve();
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1256kb

input:

300 20
0.00379430 0.00378180 0.00857190 0.00919620 0.00396670 0.00176760 0.00511380 0.00793840 0.005...

output:

0.0038

result:

ok single line: '0.0038'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1260kb

input:

300 69
0.03642550 0.00870610 0.00174390 0.00728740 0.00917590 0.00276320 0.00788090 0.00688300 0.000...

output:

0.0367

result:

ok single line: '0.0367'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1200kb

input:

300 1
0.02275200 0.00255280 0.00714900 0.00673530 0.00625580 0.00952860 0.00503680 0.00361520 0.0085...

output:

0.0228

result:

ok single line: '0.0228'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1252kb

input:

300 34
0.01174930 0.00237960 0.00725200 0.00622610 0.00092020 0.00915390 0.00050940 0.00135760 0.006...

output:

0.0118

result:

ok single line: '0.0118'

Test #5:

score: 10
Accepted
time: 6ms
memory: 1260kb

input:

300 180
0.03276550 0.00945640 0.00095320 0.00353310 0.00647080 0.00637530 0.00059110 0.00265000 0.00...

output:

0.0331

result:

ok single line: '0.0331'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1256kb

input:

300 78
0.07426740 0.00030970 0.00922200 0.00879440 0.00434000 0.00690410 0.00787240 0.00838550 0.005...

output:

0.0743

result:

ok single line: '0.0743'

Test #7:

score: 10
Accepted
time: 0ms
memory: 1256kb

input:

300 21
0.03122890 0.00933980 0.00300750 0.00424390 0.00213370 0.00940520 0.00636220 0.00227220 0.007...

output:

0.0315

result:

ok single line: '0.0315'

Test #8:

score: 10
Accepted
time: 0ms
memory: 1244kb

input:

6 4
0.64261410 0.35418080 0.00144510 0.00171790 0.00002830 0.00001380

output:

0.9831

result:

ok single line: '0.9831'

Test #9:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

6 1
0.23944990 0.51892380 0.07985400 0.07066520 0.03907530 0.05203180

output:

0.2394

result:

ok single line: '0.2394'

Test #10:

score: 10
Accepted
time: 0ms
memory: 1216kb

input:

6 3
1 0 0 0 0 0

output:

1.0000

result:

ok single line: '1.0000'