Submission #21295

# Submission time Handle Problem Language Result Execution time Memory
21295 2017-04-12T14:24:42 Z suzy 순열 (kriii4_T) C++14
100 / 100
369 ms 8928 KB
#include <stdio.h>

#define MOD 1000000007

typedef long long lli;

lli fac[1000002];
lli pw(lli n, lli x) {
	if(x==0) return 1;
	if(x%2) return n*pw(n,x-1)%MOD;
	else { lli ret=pw(n,x/2); return ret*ret%MOD; }
}

int main() {
	lli n, k;
	fac[0]=1;
	for(lli i=1;i<=1000001;i++)
		fac[i]=fac[i-1]*i%MOD;
	scanf("%lld %lld",&n,&k); k++;
	if(k>n) {
		puts("0"); return 0;
	}
	lli res=0, ncl=fac[n+1]*pw(fac[n-k],MOD-2)%MOD*pw(fac[k+1],MOD-2)%MOD;
	for(lli l=k;l<=n;l++) {
		res+=(n-l+1)*fac[l]%MOD*fac[n-l]%MOD*ncl%MOD;
		res%=MOD;
		ncl=ncl*(n-l)%MOD*pw(l+2,MOD-2)%MOD;
	}
	printf("%lld\n",res);
	return 0;
}

Compilation message

T.cpp: In function 'int main()':
T.cpp:19:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n,&k); k++;
                          ^

# Verdict Execution time Memory Grader output
1 Correct 6 ms 8928 KB Output is correct
2 Correct 6 ms 8928 KB Output is correct
3 Correct 3 ms 8928 KB Output is correct
4 Correct 6 ms 8928 KB Output is correct
5 Correct 6 ms 8928 KB Output is correct
6 Correct 9 ms 8928 KB Output is correct
7 Correct 9 ms 8928 KB Output is correct
8 Correct 6 ms 8928 KB Output is correct
9 Correct 3 ms 8928 KB Output is correct
10 Correct 9 ms 8928 KB Output is correct
11 Correct 0 ms 8928 KB Output is correct
12 Correct 6 ms 8928 KB Output is correct
13 Correct 3 ms 8928 KB Output is correct
14 Correct 3 ms 8928 KB Output is correct
15 Correct 6 ms 8928 KB Output is correct
16 Correct 3 ms 8928 KB Output is correct
17 Correct 3 ms 8928 KB Output is correct
18 Correct 3 ms 8928 KB Output is correct
19 Correct 6 ms 8928 KB Output is correct
20 Correct 9 ms 8928 KB Output is correct
21 Correct 9 ms 8928 KB Output is correct
22 Correct 9 ms 8928 KB Output is correct
23 Correct 6 ms 8928 KB Output is correct
24 Correct 6 ms 8928 KB Output is correct
25 Correct 6 ms 8928 KB Output is correct
26 Correct 9 ms 8928 KB Output is correct
27 Correct 9 ms 8928 KB Output is correct
28 Correct 9 ms 8928 KB Output is correct
29 Correct 9 ms 8928 KB Output is correct
30 Correct 6 ms 8928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 316 ms 8928 KB Output is correct
2 Correct 109 ms 8928 KB Output is correct
3 Correct 53 ms 8928 KB Output is correct
4 Correct 33 ms 8928 KB Output is correct
5 Correct 43 ms 8928 KB Output is correct
6 Correct 29 ms 8928 KB Output is correct
7 Correct 253 ms 8928 KB Output is correct
8 Correct 156 ms 8928 KB Output is correct
9 Correct 56 ms 8928 KB Output is correct
10 Correct 13 ms 8928 KB Output is correct
11 Correct 113 ms 8928 KB Output is correct
12 Correct 9 ms 8928 KB Output is correct
13 Correct 56 ms 8928 KB Output is correct
14 Correct 226 ms 8928 KB Output is correct
15 Correct 143 ms 8928 KB Output is correct
16 Correct 243 ms 8928 KB Output is correct
17 Correct 99 ms 8928 KB Output is correct
18 Correct 89 ms 8928 KB Output is correct
19 Correct 23 ms 8928 KB Output is correct
20 Correct 123 ms 8928 KB Output is correct
21 Correct 83 ms 8928 KB Output is correct
22 Correct 193 ms 8928 KB Output is correct
23 Correct 79 ms 8928 KB Output is correct
24 Correct 43 ms 8928 KB Output is correct
25 Correct 43 ms 8928 KB Output is correct
26 Correct 143 ms 8928 KB Output is correct
27 Correct 16 ms 8928 KB Output is correct
28 Correct 0 ms 8928 KB Output is correct
29 Correct 366 ms 8928 KB Output is correct
30 Correct 369 ms 8928 KB Output is correct