답안 #19960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19960 2016-02-25T07:50:23 Z gs13068 순열 (kriii4_T) C++
100 / 100
367 ms 8896 KB
#include <cstdio>
#include <algorithm>

const int p = 1000000007;

using namespace std;

int f(int x, int y)
{
	return y & 1 ? (long long)f(x, y ^ 1)*x%p : y ? f((long long)x*x%p, y >> 1) : 1;
}

int fac[1000001];
int inv[1000001];

int main()
{
	int i, j, n, m, r = 0;
	scanf("%d%d", &n, &m);
	fac[0] = 1;
	for (i = 1; i <= n + 1; i++) fac[i] = (long long)fac[i - 1] * i % p;
	inv[n + 1] = f(fac[n + 1], p - 2);
	for (i = n + 1; i >= 1; i--) inv[i - 1] = (long long)inv[i] * i % p;
	for (i = 0; i < n - m; i++)
	{
		j = fac[n - i];
		j = (long long)j * fac[n - m + 1] % p;
		j = (long long)j * inv[n - m - i - 1] % p;
		j = (long long)j * f(i + 2, p - 2) % p;
		r = (r + j) % p;
	}
	printf("%d", r);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8896 KB Output is correct
2 Correct 0 ms 8896 KB Output is correct
3 Correct 0 ms 8896 KB Output is correct
4 Correct 0 ms 8896 KB Output is correct
5 Correct 0 ms 8896 KB Output is correct
6 Correct 0 ms 8896 KB Output is correct
7 Correct 0 ms 8896 KB Output is correct
8 Correct 0 ms 8896 KB Output is correct
9 Correct 0 ms 8896 KB Output is correct
10 Correct 0 ms 8896 KB Output is correct
11 Correct 0 ms 8896 KB Output is correct
12 Correct 0 ms 8896 KB Output is correct
13 Correct 0 ms 8896 KB Output is correct
14 Correct 0 ms 8896 KB Output is correct
15 Correct 0 ms 8896 KB Output is correct
16 Correct 0 ms 8896 KB Output is correct
17 Correct 0 ms 8896 KB Output is correct
18 Correct 0 ms 8896 KB Output is correct
19 Correct 0 ms 8896 KB Output is correct
20 Correct 0 ms 8896 KB Output is correct
21 Correct 0 ms 8896 KB Output is correct
22 Correct 0 ms 8896 KB Output is correct
23 Correct 0 ms 8896 KB Output is correct
24 Correct 0 ms 8896 KB Output is correct
25 Correct 0 ms 8896 KB Output is correct
26 Correct 0 ms 8896 KB Output is correct
27 Correct 0 ms 8896 KB Output is correct
28 Correct 0 ms 8896 KB Output is correct
29 Correct 0 ms 8896 KB Output is correct
30 Correct 0 ms 8896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 327 ms 8896 KB Output is correct
2 Correct 115 ms 8896 KB Output is correct
3 Correct 45 ms 8896 KB Output is correct
4 Correct 31 ms 8896 KB Output is correct
5 Correct 45 ms 8896 KB Output is correct
6 Correct 40 ms 8896 KB Output is correct
7 Correct 259 ms 8896 KB Output is correct
8 Correct 159 ms 8896 KB Output is correct
9 Correct 55 ms 8896 KB Output is correct
10 Correct 10 ms 8896 KB Output is correct
11 Correct 109 ms 8896 KB Output is correct
12 Correct 15 ms 8896 KB Output is correct
13 Correct 59 ms 8896 KB Output is correct
14 Correct 231 ms 8896 KB Output is correct
15 Correct 131 ms 8896 KB Output is correct
16 Correct 208 ms 8896 KB Output is correct
17 Correct 95 ms 8896 KB Output is correct
18 Correct 94 ms 8896 KB Output is correct
19 Correct 25 ms 8896 KB Output is correct
20 Correct 124 ms 8896 KB Output is correct
21 Correct 74 ms 8896 KB Output is correct
22 Correct 200 ms 8896 KB Output is correct
23 Correct 80 ms 8896 KB Output is correct
24 Correct 35 ms 8896 KB Output is correct
25 Correct 51 ms 8896 KB Output is correct
26 Correct 136 ms 8896 KB Output is correct
27 Correct 16 ms 8896 KB Output is correct
28 Correct 18 ms 8896 KB Output is correct
29 Correct 367 ms 8896 KB Output is correct
30 Correct 367 ms 8896 KB Output is correct