QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#812000 | #7329. Independent Events | owenytz | WA | 0ms | 51040kb | C++14 | 1.9kb | 2024-12-13 10:37:07 | 2024-12-13 10:37:08 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define deb(x) cerr<<"deb:"<<__LINE__<<" "<<#x<<"="<<x<<"\n"
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
//char buf[1<<21],*p1=buf,*p2=buf;
inline ll read()
{
ll sum=0,l=1;char c=getchar();
while(!isdigit(c)){if(c=='-')l=-1;c=getchar();}
while(isdigit(c)){sum=(sum<<1)+(sum<<3)+(c^48);c=getchar();}
return sum*l;
}
const ll n=20;
long double c[100100],tl[400100],tr[400100],ts[21][400100],tg[400100];
void Update(ll x)
{
for(ll i=1;i<=n;i++)ts[i][x]=ts[i][x*2]+ts[i][x*2+1];
}
void upd(ll x,long double y)
{
tg[x]*=y;
long double now=y;
for(ll i=1;i<=n;i++)
{
ts[i][x]*=now;
now*=y;
}
}
void Push(ll x)
{
if(tg[x]!=1)
{
upd(x*2,tg[x]);
upd(x*2+1,tg[x]);
tg[x]=1;
}
}
void Build(ll x,ll l,ll r)
{
tl[x]=l;
tr[x]=r;
tg[x]=1;
if(l==r)
{
c[l]=-c[l];
long double now=c[l];
for(ll i=1;i<=n;i++)
{
ts[i][x]=now/i;
now*=c[l];
}
return;
}
ll mid=(l+r)/2;
Build(x*2,l,mid);
Build(x*2+1,mid+1,r);
Update(x);
}
void Add(ll x,ll l,ll r,long double y)
{
if(l<=tl[x]&&tr[x]<=r)
{
upd(x,y);
return;
}
Push(x);
ll mid=(tl[x]+tr[x])/2;
if(l<=mid)Add(x*2,l,r,y);
if(mid<r)Add(x*2+1,l,r,y);
Update(x);
}
long double Query(ll x,ll l,ll r)
{
if(l<=tl[x]&&tr[x]<=r)
{
long double res=0;
ll pl=1;
for(ll i=1;i<=n;i++)
{
res+=ts[i][x]*pl;
pl*=-1;
}
return res;
}
Push(x);
ll mid=(tl[x]+tr[x])/2;
if(mid<l)return Query(x*2+1,l,r);
else if(r<=mid)return Query(x*2,l,r);
else return Query(x*2,l,r)+Query(x*2+1,l,r);
}
int main()
{
ll a,b;cin>>a>>b;
for(ll i=1;i<=a;i++)cin>>c[i];
Build(1,1,a);
for(ll i=1;i<=b;i++)
{
ll op,d,e;cin>>op>>d>>e;
if(op==1)
{
long double f;
cin>>f;
Add(1,d,e,f);
}
else
{
printf("%.20Lf\n",Query(1,d,e));
}
if(i==36)return 0;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 51040kb
input:
6 5 0.01000 0.09871 0.00005 0.00999 0.01234 0.02345 0 1 6 1 3 4 10.00000 0 1 6 1 1 2 0.05000 0 1 6
output:
-0.16021487727848474649 -0.25587417689480757314 -0.14734347732072094072
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 50932kb
input:
54 36 0.00014 0.00020 0.00054 0.00084 0.00088 0.00095 0.00031 0.00077 0.00054 0.00050 0.00024 0.00057 0.00066 0.00029 0.00084 0.00031 0.00024 0.00091 0.00063 0.00069 0.00024 0.00041 0.00090 0.00057 0.00071 0.00031 0.00047 0.00016 0.00063 0.00074 0.00040 0.00077 0.00058 0.00049 0.00013 0.00076 0.0007...
output:
-0.00094044207705666747 -0.17285693984128141989 -0.64724368410974252941 -0.00144732047221210144 -0.09295564190549821453 -0.93078328060097830995 -0.06410239318769475523 -0.09166404281803549134 -0.04774269239055688012 -0.00085018090138477359 -0.03185781098379997929 -0.23731222356479127256 -0.517538000...
result:
wrong output format Unexpected end of file - double expected