답안 #20101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20101 2016-02-25T13:31:48 Z imsifile 순열 (kriii4_T) C++
100 / 100
821 ms 16724 KB
#include<stdio.h>
#include<memory.h>
#define mod 1000000007
#define inv(a) exp(a,mod-2)

typedef long long lld;

lld exp(lld a, lld b){
	if(b==0)return 1;
	lld k=exp(a, b/2);
	k=(k*k)%mod;
	if(b%2)k=(k*a)%mod;
	return k;
}

lld fac[1001001], rfac[1001001];

void init(){
	lld i;
	fac[0]=rfac[0]=1;
	for(i=1; i<=1000001; i++){
		fac[i]=(fac[i-1]*i)%mod;
		rfac[i]=inv(fac[i]);
	}
}

lld comb(lld a, lld b){
	return fac[a]*rfac[b]%mod*rfac[a-b]%mod;
}

lld n, k, sum;

int main(){
	lld i;
	init();
	scanf("%lld%lld", &n, &k);
	for(i=k+1; i<=n; i++){
		lld im = fac[n+1]*(n-i+1)%mod * inv(i+1);
		im = (im%mod+mod)%mod;
		sum += im, sum%=mod;
	}
	printf("%lld", sum);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 412 ms 16724 KB Output is correct
2 Correct 409 ms 16724 KB Output is correct
3 Correct 410 ms 16724 KB Output is correct
4 Correct 406 ms 16724 KB Output is correct
5 Correct 410 ms 16724 KB Output is correct
6 Correct 409 ms 16724 KB Output is correct
7 Correct 402 ms 16724 KB Output is correct
8 Correct 406 ms 16724 KB Output is correct
9 Correct 410 ms 16724 KB Output is correct
10 Correct 411 ms 16724 KB Output is correct
11 Correct 410 ms 16724 KB Output is correct
12 Correct 409 ms 16724 KB Output is correct
13 Correct 405 ms 16724 KB Output is correct
14 Correct 402 ms 16724 KB Output is correct
15 Correct 406 ms 16724 KB Output is correct
16 Correct 406 ms 16724 KB Output is correct
17 Correct 411 ms 16724 KB Output is correct
18 Correct 411 ms 16724 KB Output is correct
19 Correct 407 ms 16724 KB Output is correct
20 Correct 406 ms 16724 KB Output is correct
21 Correct 411 ms 16724 KB Output is correct
22 Correct 411 ms 16724 KB Output is correct
23 Correct 410 ms 16724 KB Output is correct
24 Correct 411 ms 16724 KB Output is correct
25 Correct 411 ms 16724 KB Output is correct
26 Correct 411 ms 16724 KB Output is correct
27 Correct 406 ms 16724 KB Output is correct
28 Correct 407 ms 16724 KB Output is correct
29 Correct 411 ms 16724 KB Output is correct
30 Correct 407 ms 16724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 776 ms 16724 KB Output is correct
2 Correct 526 ms 16724 KB Output is correct
3 Correct 455 ms 16724 KB Output is correct
4 Correct 438 ms 16724 KB Output is correct
5 Correct 458 ms 16724 KB Output is correct
6 Correct 442 ms 16724 KB Output is correct
7 Correct 702 ms 16724 KB Output is correct
8 Correct 586 ms 16724 KB Output is correct
9 Correct 470 ms 16724 KB Output is correct
10 Correct 415 ms 16724 KB Output is correct
11 Correct 528 ms 16724 KB Output is correct
12 Correct 411 ms 16724 KB Output is correct
13 Correct 460 ms 16724 KB Output is correct
14 Correct 663 ms 16724 KB Output is correct
15 Correct 556 ms 16724 KB Output is correct
16 Correct 644 ms 16724 KB Output is correct
17 Correct 513 ms 16724 KB Output is correct
18 Correct 512 ms 16724 KB Output is correct
19 Correct 432 ms 16724 KB Output is correct
20 Correct 536 ms 16724 KB Output is correct
21 Correct 495 ms 16724 KB Output is correct
22 Correct 624 ms 16724 KB Output is correct
23 Correct 486 ms 16724 KB Output is correct
24 Correct 452 ms 16724 KB Output is correct
25 Correct 454 ms 16724 KB Output is correct
26 Correct 563 ms 16724 KB Output is correct
27 Correct 420 ms 16724 KB Output is correct
28 Correct 408 ms 16724 KB Output is correct
29 Correct 821 ms 16724 KB Output is correct
30 Correct 818 ms 16724 KB Output is correct