QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211578 | #5749. Directed Vertex Cacti | sinsop90 | WA | 0ms | 3656kb | C++14 | 585b | 2023-10-12 18:45:03 | 2023-10-12 18:45:04 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 9;
int n, m;
int ksm(int p, int q) {
int res = 1;
while(q) {
if(q & 1) res = res * p % mod;
p = p * p % mod;
q >>= 1;
}
return res;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> m;
n = n * (n - 1) / 2;
n %= mod;
int fac = 1;
for(int i = 1;i <= m;i++) fac = fac * i % mod;
fac = ksm(fac, mod - 2);
for(int i = n;i >= n - m + 1;i--) fac = fac * i % mod;
for(int i = 1;i <= n;i++) fac = fac * i % mod;
cout << fac;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
3 1
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3608kb
input:
4 4
output:
10800
result:
wrong answer 1st numbers differ - expected: '360', found: '10800'