QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#454150 | #1264. Lower Algorithmics | Kevin5307 | WA | 1739ms | 52688kb | C++23 | 1.7kb | 2024-06-24 16:54:05 | 2024-06-24 16:54:05 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rsrt(x) sort(rALL(x))
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
const ll mod=1004535809;
ll ksm(ll a,ll b)
{
ll ans=1;
while(b)
{
if(b&1) ans=ans*a%mod;
b>>=1;
a=a*a%mod;
}
return ans;
}
void ntt(ll *a,int len,bool t)
{
vector<int> rev(len);
for(int i=0;i<len;i++)
rev[i]=(rev[i>>1]>>1)|((i&1)*(len>>1));
for(int i=0;i<len;i++)
if(rev[i]<i)
swap(a[i],a[rev[i]]);
for(int i=1;i<len;i<<=1)
{
ll gn=ksm(!t?3:ksm(3,mod-2),(mod-1)/i/2);
for(int j=0;j<len;j+=(i<<1))
{
ll g0=1;
for(int k=0;k<i;k++,g0=g0*gn%mod)
{
ll x=a[j+k],y=g0*a[i+j+k]%mod;
a[j+k]=(x+y)%mod;
a[i+j+k]=(x+mod-y)%mod;
}
}
}
if(t)
for(int i=0;i<len;i++)
a[i]=a[i]*ksm(len,mod-2)%mod;
}
ll a[1<<22];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,l,r;
cin>>n>>l>>r;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
a[x]=1;
}
ntt(a,1<<22,0);
for(int i=0;i<1<<22;i++)
a[i]=(a[i]==1?r-l+1:(ksm(a[i],r+1)-ksm(a[i],l)+mod)*ksm(a[i]+mod-1,mod-2))%mod;
ntt(a,1<<22,1);
int res=0;
for(int i=0;i<1<<22;i++)
if(a[i])
res++;
cout<<res<<endl;
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1739ms
memory: 52688kb
input:
2 1 2 1 2
output:
4194304
result:
wrong answer expected '4', found '4194304'