QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#715128#7962. 前缀和sdmrlh#WA 0ms3872kbC++14797b2024-11-06 10:32:282024-11-06 10:32:28

Judging History

This is the latest submission verdict.

  • [2024-11-06 10:32:28]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3872kb
  • [2024-11-06 10:32:28]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld%lld",&x,&y)
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pf(x) printf("%lld",x)
#define pii pair<int,int> 
#define f first 
#define s second
#define int long long



//
int  m,ll,rr;
double p,pp;
//
//


void solve()
{	
	cin>>m>>pp>>ll>>rr;
	p=1/pp;
	
	double res=1;
	int l = -1,r=1e9+10;
	while(l+1<r)
	{
		int mid  =l+r>>1;
		if(p*(double)mid>=ll) r=mid;
		else l=mid;
	}
	res-=r;
	
	l = -1,r=1e9+10;
	while(l+1<r)
	{
		int mid  =l+r>>1;
		if(p*(double)mid>rr) r=mid;
		else l=mid;
	}
	res+=l;
	
	cout<<max(0.0,res)<<endl;
}
signed main()
{
	IOS;
	int _=1;
	while(_--)
		solve();
	return 0;
}

详细

Test #1:

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

input:

3 0.5 1 2

output:

1

result:

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

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3864kb

input:

1 0.529148 1 1

output:

0

result:

wrong answer 1st numbers differ - expected: '0.5291480', found: '0.0000000', error = '0.5291480'