QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#352181#7962. 前缀和wuzhichenAC ✓0ms3900kbC++14563b2024-03-12 22:47:262024-03-12 22:47:27

Judging History

This is the latest submission verdict.

  • [2024-03-12 22:47:27]
  • Judged
  • Verdict: AC
  • Time: 0ms
  • Memory: 3900kb
  • [2024-03-12 22:47:26]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const double eps=1e-8;
int n,l,r;double p,ans=0.0;
int fact(int n){
	int ans=1;
	for(int i=1;i<=n;i++)ans*=i;
	return ans;
}
double comb(int n,int m){
	if(m>n)return 0.0;
	return fact(n)*1.0/(fact(m)*1.0*fact(n-m));
}
int main(){
	scanf("%d %lf %d %d",&n,&p,&l,&r);
	ans=(r-l+1)*1.0*p;
/*	
	for(int i=1;i<=n;i++)
		for(int j=l;j<=r;j++)
			if(j>=i)ans+=1.0*pow(p,i)*pow(1.0-p,j-i);
*/	
	printf("%.8lf",ans);
	return 0;
}
/*
3 0.5 1 2

1 0.5 1 2

1000000000 0.592692 495948205 808386938
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3884kb

input:

3 0.5 1 2

output:

1.00000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

1 0.529148 1 1

output:

0.52914800

result:

ok found '0.5291480', expected '0.5291480', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

1000000000 0.592692 495948205 808386938

output:

185179938.13192800

result:

ok found '185179938.1319280', expected '185179938.1320000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

362633210 0.587463 165288121 324679823

output:

93636728.01948899

result:

ok found '93636728.0194890', expected '93636728.0195000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3900kb

input:

763961137 0.360268 233953864 630625466

output:

142908085.06960398

result:

ok found '142908085.0696040', expected '142908085.0700000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

1000000000 0.999999 1 1000000000

output:

999999000.00000000

result:

ok found '999999000.0000000', expected '999999000.0000000', error '0.0000000'