QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#262816 | #5746. DAG Generation | w4p3r# | TL | 0ms | 3560kb | C++20 | 1.6kb | 2023-11-24 05:35:07 | 2023-11-24 05:35:08 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define db double
#define ve vector<int>
#define pa pair<int,int>
#define fr first
#define sd second
#define pb push_back
#define mp make_pair
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
inline ll read()
{
char ch = getchar();
ll s = 0, w = 1;
while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
return s * w;
}
#define N 100010
int n, inv[N], P[N];
const int mod = int(1e9 + 9);
int ksm(int a, int b)
{
int ans = 1;
while (b) {if (b & 1)ans = 1LL * ans * a % mod; b >>= 1; a = 1LL * a * a % mod;}
return ans;
}
void sol()
{
cin >> n;
int ans = 1;
inv[0] = inv[1] = 1;
for (int i = 2; i <= n; i ++)inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
for (int i = 2; i <= n; i ++)inv[i] = 1LL * inv[i] * inv[i - 1] % mod;
P[0] = 1;
for (int i = 1; i <= n; i ++)P[i] = (P[i - 1] + P[i - 1]) % mod;
for (int i = 1; i <= n; i ++)ans = 1LL * ans * (P[i] + mod - 1) % mod;
for (int i = 1; i <= n - 1; i ++)ans = 1LL * ans * ksm(1LL * P[i] * P[i] % mod, mod - 2) % mod;
ans = 1LL * ans * inv[n] % mod;
cout << (1 + mod - ans) % mod << '\n';
}
signed main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T; cin >> T;
while (T --)sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
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: 0ms
memory: 3560kb
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
Time Limit Exceeded
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 ...