#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 100111
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
ll fakt[maxn], inv[maxn];
ll fastexp(ll x, ll y){
ll ret = 1LL;
while(y){
if(y & 1)
ret = (ret * x) % MOD;
x = (x * x) % MOD;
y >>= 1;
}
return ret;
}
ll C(ll x, ll y){
ll ret = fakt[x] * inv[y] % MOD * inv[x - y] % MOD;
return ret;
}
ll eulerian_number(ll n, ll k){
ll ans = 0LL;
for(int i = 0; i <= k + 1; i++){
ll cur = fastexp(-1LL, i) * C(n + 1LL, i) % MOD * fastexp(k + 1LL - i, n) % MOD;
ans = (ans + cur + MOD) % MOD;
}
return ans;
}
void preprocess(){
fakt[0] = inv[0] = 1LL;
for(ll i = 1; i < maxn; i++){
fakt[i] = (fakt[i - 1] * i) % MOD;
inv[i] = fastexp(fakt[i], MOD - 2);
}
}
int main(){
preprocess();
ll n, k;
scanf("%lld%lld", &n, &k);
printf("%lld\n", eulerian_number(n, n - k) );
return 0;
}
Compilation message
asceticism.cpp: In function 'int main()':
asceticism.cpp:57:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld", &n, &k);
~~~~~^~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1912 KB |
Output is correct |
2 |
Correct |
19 ms |
1912 KB |
Output is correct |
3 |
Correct |
19 ms |
1920 KB |
Output is correct |
4 |
Correct |
20 ms |
2020 KB |
Output is correct |
5 |
Correct |
19 ms |
2148 KB |
Output is correct |
6 |
Correct |
19 ms |
2148 KB |
Output is correct |
7 |
Correct |
19 ms |
2148 KB |
Output is correct |
8 |
Correct |
21 ms |
2148 KB |
Output is correct |
9 |
Correct |
19 ms |
2148 KB |
Output is correct |
10 |
Correct |
19 ms |
2148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1912 KB |
Output is correct |
2 |
Correct |
19 ms |
1912 KB |
Output is correct |
3 |
Correct |
19 ms |
1920 KB |
Output is correct |
4 |
Correct |
20 ms |
2020 KB |
Output is correct |
5 |
Correct |
19 ms |
2148 KB |
Output is correct |
6 |
Correct |
19 ms |
2148 KB |
Output is correct |
7 |
Correct |
19 ms |
2148 KB |
Output is correct |
8 |
Correct |
21 ms |
2148 KB |
Output is correct |
9 |
Correct |
19 ms |
2148 KB |
Output is correct |
10 |
Correct |
19 ms |
2148 KB |
Output is correct |
11 |
Correct |
19 ms |
2224 KB |
Output is correct |
12 |
Correct |
19 ms |
2224 KB |
Output is correct |
13 |
Correct |
19 ms |
2224 KB |
Output is correct |
14 |
Correct |
19 ms |
2240 KB |
Output is correct |
15 |
Correct |
19 ms |
2240 KB |
Output is correct |
16 |
Correct |
20 ms |
2240 KB |
Output is correct |
17 |
Correct |
20 ms |
2240 KB |
Output is correct |
18 |
Correct |
19 ms |
2240 KB |
Output is correct |
19 |
Correct |
20 ms |
2240 KB |
Output is correct |
20 |
Correct |
19 ms |
2240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1912 KB |
Output is correct |
2 |
Correct |
19 ms |
1912 KB |
Output is correct |
3 |
Correct |
19 ms |
1920 KB |
Output is correct |
4 |
Correct |
20 ms |
2020 KB |
Output is correct |
5 |
Correct |
19 ms |
2148 KB |
Output is correct |
6 |
Correct |
19 ms |
2148 KB |
Output is correct |
7 |
Correct |
19 ms |
2148 KB |
Output is correct |
8 |
Correct |
21 ms |
2148 KB |
Output is correct |
9 |
Correct |
19 ms |
2148 KB |
Output is correct |
10 |
Correct |
19 ms |
2148 KB |
Output is correct |
11 |
Correct |
19 ms |
2224 KB |
Output is correct |
12 |
Correct |
19 ms |
2224 KB |
Output is correct |
13 |
Correct |
19 ms |
2224 KB |
Output is correct |
14 |
Correct |
19 ms |
2240 KB |
Output is correct |
15 |
Correct |
19 ms |
2240 KB |
Output is correct |
16 |
Correct |
20 ms |
2240 KB |
Output is correct |
17 |
Correct |
20 ms |
2240 KB |
Output is correct |
18 |
Correct |
19 ms |
2240 KB |
Output is correct |
19 |
Correct |
20 ms |
2240 KB |
Output is correct |
20 |
Correct |
19 ms |
2240 KB |
Output is correct |
21 |
Correct |
19 ms |
2240 KB |
Output is correct |
22 |
Correct |
20 ms |
2240 KB |
Output is correct |
23 |
Correct |
21 ms |
2240 KB |
Output is correct |
24 |
Correct |
19 ms |
2240 KB |
Output is correct |
25 |
Correct |
19 ms |
2240 KB |
Output is correct |
26 |
Correct |
19 ms |
2240 KB |
Output is correct |
27 |
Correct |
19 ms |
2240 KB |
Output is correct |
28 |
Correct |
19 ms |
2240 KB |
Output is correct |
29 |
Correct |
20 ms |
2244 KB |
Output is correct |
30 |
Correct |
19 ms |
2244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1912 KB |
Output is correct |
2 |
Correct |
19 ms |
1912 KB |
Output is correct |
3 |
Correct |
19 ms |
1920 KB |
Output is correct |
4 |
Correct |
20 ms |
2020 KB |
Output is correct |
5 |
Correct |
19 ms |
2148 KB |
Output is correct |
6 |
Correct |
19 ms |
2148 KB |
Output is correct |
7 |
Correct |
19 ms |
2148 KB |
Output is correct |
8 |
Correct |
21 ms |
2148 KB |
Output is correct |
9 |
Correct |
19 ms |
2148 KB |
Output is correct |
10 |
Correct |
19 ms |
2148 KB |
Output is correct |
11 |
Correct |
19 ms |
2224 KB |
Output is correct |
12 |
Correct |
19 ms |
2224 KB |
Output is correct |
13 |
Correct |
19 ms |
2224 KB |
Output is correct |
14 |
Correct |
19 ms |
2240 KB |
Output is correct |
15 |
Correct |
19 ms |
2240 KB |
Output is correct |
16 |
Correct |
20 ms |
2240 KB |
Output is correct |
17 |
Correct |
20 ms |
2240 KB |
Output is correct |
18 |
Correct |
19 ms |
2240 KB |
Output is correct |
19 |
Correct |
20 ms |
2240 KB |
Output is correct |
20 |
Correct |
19 ms |
2240 KB |
Output is correct |
21 |
Correct |
19 ms |
2240 KB |
Output is correct |
22 |
Correct |
20 ms |
2240 KB |
Output is correct |
23 |
Correct |
21 ms |
2240 KB |
Output is correct |
24 |
Correct |
19 ms |
2240 KB |
Output is correct |
25 |
Correct |
19 ms |
2240 KB |
Output is correct |
26 |
Correct |
19 ms |
2240 KB |
Output is correct |
27 |
Correct |
19 ms |
2240 KB |
Output is correct |
28 |
Correct |
19 ms |
2240 KB |
Output is correct |
29 |
Correct |
20 ms |
2244 KB |
Output is correct |
30 |
Correct |
19 ms |
2244 KB |
Output is correct |
31 |
Correct |
35 ms |
2244 KB |
Output is correct |
32 |
Correct |
35 ms |
2244 KB |
Output is correct |
33 |
Correct |
34 ms |
2244 KB |
Output is correct |
34 |
Correct |
32 ms |
2244 KB |
Output is correct |
35 |
Correct |
22 ms |
2244 KB |
Output is correct |
36 |
Correct |
21 ms |
2244 KB |
Output is correct |
37 |
Correct |
19 ms |
2244 KB |
Output is correct |
38 |
Correct |
20 ms |
2244 KB |
Output is correct |
39 |
Correct |
25 ms |
2244 KB |
Output is correct |
40 |
Correct |
31 ms |
2276 KB |
Output is correct |