QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#557793 | #5746. DAG Generation | louhao088 | WA | 10ms | 10016kb | C++23 | 1.2kb | 2024-09-11 11:26:24 | 2024-09-11 11:26:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi pair<int,int>
#define pb push_back
#define ls (rt<<1)
#define rs (rt<<1|1)
#define mp make_pair
#define lowbit(i) (i&(-i))
#define int long long
#define mid ((l+r)/2)
inline int read(){
int x=0;char ch=getchar();bool f=0;
for(;!isdigit(ch);ch=getchar())if(ch=='-')f=1;
for(;isdigit(ch);ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
if(f)x=-x;return x;
}
const int maxn=3e5+5,mod=1e9+9;
int n,x,f[maxn],ans=0,pw[maxn],T,fac[maxn];
int g[maxn];
int Pow(int x,int y){
int res=1;
while(y){
if(y&1){
res=res*x%mod;
}y=y/2;x=x*x%mod;
}return res;
}
void init(int n){
pw[0]=1;fac[0]=1;g[0]=1;
for(int i=1;i<=n;i++)pw[i]=pw[i-1]*2%mod,fac[i]=fac[i-1]*i%mod;
for(int i=1;i<=n;i++)g[i]=g[i-1]*(pw[i]-1)%mod;
for(int i=1;i<=n;i++){
int t=g[i]*Pow(fac[i]*Pow(2,(i)*(i-1))%mod,mod-2)%mod;
f[i]=(mod+1-t)%mod;
//cout<<g[i]<<" "<<fac[i]<<" "<<f[i]<<" "<<Pow(2,n*(n-1))<<endl;
}
}
signed main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
init(100);
cin>>T;
for(int i=1;i<=T;i++){
cin>>x;
printf("%lld\n",f[x]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 9956kb
input:
4 1 2 3 100
output:
0 375000004 117187502 778748905
result:
ok 4 number(s): "0 375000004 117187502 778748905"
Test #2:
score: 0
Accepted
time: 1ms
memory: 10016kb
input:
5 1 2 3 4 5
output:
0 375000004 117187502 213897708 995024095
result:
ok 5 number(s): "0 375000004 117187502 213897708 995024095"
Test #3:
score: -100
Wrong Answer
time: 10ms
memory: 9948kb
input:
100000 64268 66535 9758 42907 84212 83488 27748 86198 80658 11614 93419 2528 96160 79473 83517 43109 37111 46603 93665 54540 84236 62717 24719 57225 8333 15728 40821 31719 13096 75018 76890 46244 75863 59618 67460 10326 84775 11276 83363 72071 9353 94316 9469 3969 78568 53071 96835 50125 2728 46756 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st numbers differ - expected: '517835222', found: '0'