QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#829886 | #1264. Lower Algorithmics | World_Creater | TL | 856ms | 80988kb | C++17 | 1.0kb | 2024-12-24 14:32:55 | 2024-12-24 14:32:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long double db;
int n,l,r,lim=1<<21,rev[5000005],ans;
complex<db> a[5000005],b[5000005];
const db pi=acos(-1),eps=1e-9;
void FFT(complex<db> a[],int inv)
{
for(int i=0;i<=lim;i++)
{
if(i<rev[i]) swap(a[i],a[rev[i]]);
}
for(int w=1;w<lim;w*=2)
{
complex<db> com(cos(pi/w),inv*sin(pi/w));
for(int i=0;i<lim;i+=w*2)
{
complex<db> o(1,0);
for(int j=0;j<w;j++)
{
complex<db> x=a[i+j],y=o*a[i+j+w];
a[i+j]=x+y,a[i+j+w]=x-y;
o*=com;
}
}
}
}
int main()
{
cin>>n>>l>>r;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
a[x]=complex<db>(1,0);
}
for(int i=0;i<lim;i++)
{
rev[i]=(rev[i>>1]>>1);
if(i&1) rev[i]|=lim>>1;
}
FFT(a,1);
for(int i=0;i<lim;i++)
{
if(fabs(a[i].imag())<eps&&fabs(a[i].real()-1)<eps) a[i]*=r-l+1;
else a[i]=(pow(a[i],r+1)-pow(a[i],l))/(a[i]-(complex<db>(1,0)));
}
FFT(a,-1);
for(int i=0;i<lim;i++)
{
if(fabs(a[i].real()/lim)>eps) ans++;
}
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 828ms
memory: 79112kb
input:
2 1 2 1 2
output:
4
result:
ok answer is '4'
Test #2:
score: 0
Accepted
time: 851ms
memory: 79120kb
input:
3 1 3 1 3 10
output:
18
result:
ok answer is '18'
Test #3:
score: 0
Accepted
time: 856ms
memory: 80988kb
input:
6 3 5 1 2 3 4 5 6
output:
28
result:
ok answer is '28'
Test #4:
score: 0
Accepted
time: 840ms
memory: 79164kb
input:
3 1 3 1 3 4
output:
12
result:
ok answer is '12'
Test #5:
score: -100
Time Limit Exceeded
input:
500 1 2000 6 8 9 10 11 14 16 19 23 24 25 30 31 33 34 38 44 46 48 49 52 53 55 56 58 60 64 65 68 69 70 71 72 74 75 77 79 81 83 84 88 89 93 95 98 103 105 108 109 110 111 118 119 120 121 123 125 129 130 132 134 136 137 138 140 141 144 149 154 155 159 160 161 163 165 166 169 170 172 173 174 175 176 177 1...