QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#138191#5746. DAG Generationle0nAC ✓11ms3940kbC++141.0kb2023-08-11 08:51:072023-08-11 08:51:09

Judging History

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

  • [2023-08-11 08:51:09]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:3940kb
  • [2023-08-11 08:51:07]
  • 提交

answer

#include <cstdio> 

using namespace std;
typedef long long ll;

const int mod = 1e9 + 9, i2 = 5e8 + 5;
int qpow(int x, int y)
{
	int ans = 1;
	while(y)
	{
		if(y & 1)
			ans = (ll)ans * x % mod;
		x = (ll)x * x % mod;
		y >>= 1;
	}
	return ans;
}
int fac2[100005], fac[100005], inv[100005], i2p[100005], i2w[100005], ans[100005];

int main()
{
	int t, n, i, p;
	n = 1e5;
	fac[0] = fac2[0] = 1;
	for(i = 1; i <= n; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	for(i = 1, p = 1; i <= n; i++, p = (p + p + 1) % mod)
		fac2[i] = (ll)fac2[i - 1] * p % mod;
	inv[n] = qpow(fac[n], mod - 2);
	for(i = n; i >= 1; i--)
		inv[i - 1] = (ll)inv[i] * i % mod;
	i2p[0] = i2w[0] = 1;
	for(i = 1; i <= n; i++)
	{
		i2p[i] = (ll)i2p[i - 1] * i2 % mod;
		i2w[i] = (ll)i2w[i - 1] * i2p[i - 1] % mod;
	}
	for(i = 1; i <= n; i++)
		ans[i] = (ll)fac2[i] * inv[i] % mod * i2w[i] % mod * i2w[i] % mod;
	scanf("%d", &t);
	while(t--)
	{
		scanf("%d", &n);
		printf("%d\n", (mod + 1 - ans[n]) % mod); 
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 3924kb

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: 3ms
memory: 3916kb

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: 11ms
memory: 3940kb

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