QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#490228#5746. DAG Generationucup-team1525#AC ✓26ms5500kbC++20962b2024-07-25 13:12:202024-07-25 13:12:20

Judging History

你现在查看的是最新测评结果

  • [2024-07-25 13:12:20]
  • 评测
  • 测评结果:AC
  • 用时:26ms
  • 内存:5500kb
  • [2024-07-25 13:12:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5;
const int mod=1e9+9;
int fac[N+5],ifac[N+5];
int kp[N+5],ans[N+5];
int add(int x,int y){ return (x+=y)>=mod?x-mod:x; }
int sub(int x,int y){ return (x-=y)<0?x+mod:x; }
int ksm(ll x,int tp,int s=1){
    for(;tp;x=x*x%mod,tp>>=1) if(tp&1) s=x*s%mod;
    return s;
}
void prep(){
    fac[0]=1;
    for(int i=1;i<=N;i++) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[N]=ksm(fac[N],mod-2);
    for(int i=N;i;i--) ifac[i-1]=1ll*ifac[i]*i%mod;
    kp[0]=1;
    for(int i=1;i<=N;i++) kp[i]=add(kp[i-1],kp[i-1]);
    ans[0]=1;
    for(int i=1;i<=N;i++)
        ans[i]=1ll*ans[i-1]*(kp[i]-1)%mod;
    for(int i=1;i<=N;i++)
        ans[i]=ksm(2,mod-1-1ll*i*(i-1)%(mod-1),1ll*ans[i]*ifac[i]%mod);
}
int n;
void solve(){
    scanf("%d",&n);
    printf("%d\n",sub(1,ans[n]));
}
int main(){
    prep();
    int t; scanf("%d",&t);
    while(t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 14ms
memory: 5360kb

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: 14ms
memory: 5500kb

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: 0
Accepted
time: 26ms
memory: 5436kb

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:

517835222
425525315
415451955
804144524
465143750
248034271
13166687
703325946
341000020
13797696
905521918
608927142
591090671
501585335
146368913
172358003
116621710
241875456
448868678
155749600
350155635
599343092
400133403
78229211
452768218
582618783
811512224
912730301
470660521
250329917
370...

result:

ok 100000 numbers