답안 #137487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137487 2019-07-28T04:45:54 Z dndhk Asceticism (JOI18_asceticism) C++14
100 / 100
81 ms 1272 KB
#include <bits/stdc++.h>

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll DIV = 1000000007;

const int MAX_N = 100000;
int N, K;

ll ans;
ll pac[MAX_N+10];

ll multi(ll x, ll y){
	if(y==0)	return 1;
	if(y==1)	return x%DIV;
	ll m = multi(x, y/2);
	if(y%2){
		return m*m%DIV*x%DIV;
	}
	return m*m%DIV;
}

ll inv(ll x){
	return multi(x, DIV-2);
}

int main(){
	pac[0] = 1;
	for(ll i=1; i<MAX_N+10; i++){
		pac[i] = (pac[i-1] * i)%DIV;
	}
	scanf("%d%d", &N, &K);
	K--;
	ll t = 1;
	for(int i=0; i<=K; i++){
		ll add = (t * ((pac[N+1] * inv(pac[N-i+1])%DIV) * inv(pac[i])%DIV * multi(K+1-i, N))) % DIV;
		add = (add + DIV)%DIV;
		ans = (ans + add) % DIV;
		t = -t;
	}
	cout<<ans;
	return 0;
}

Compilation message

asceticism.cpp: In function 'int main()':
asceticism.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &K);
  ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 3 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 3 ms 1144 KB Output is correct
11 Correct 3 ms 1144 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1144 KB Output is correct
14 Correct 3 ms 1144 KB Output is correct
15 Correct 3 ms 1144 KB Output is correct
16 Correct 3 ms 1144 KB Output is correct
17 Correct 3 ms 1144 KB Output is correct
18 Correct 3 ms 1144 KB Output is correct
19 Correct 3 ms 1144 KB Output is correct
20 Correct 3 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 3 ms 1144 KB Output is correct
11 Correct 3 ms 1144 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1144 KB Output is correct
14 Correct 3 ms 1144 KB Output is correct
15 Correct 3 ms 1144 KB Output is correct
16 Correct 3 ms 1144 KB Output is correct
17 Correct 3 ms 1144 KB Output is correct
18 Correct 3 ms 1144 KB Output is correct
19 Correct 3 ms 1144 KB Output is correct
20 Correct 3 ms 1020 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1144 KB Output is correct
23 Correct 3 ms 1144 KB Output is correct
24 Correct 4 ms 1144 KB Output is correct
25 Correct 4 ms 1144 KB Output is correct
26 Correct 4 ms 1144 KB Output is correct
27 Correct 4 ms 1144 KB Output is correct
28 Correct 3 ms 1144 KB Output is correct
29 Correct 3 ms 1016 KB Output is correct
30 Correct 4 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 3 ms 1144 KB Output is correct
11 Correct 3 ms 1144 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1144 KB Output is correct
14 Correct 3 ms 1144 KB Output is correct
15 Correct 3 ms 1144 KB Output is correct
16 Correct 3 ms 1144 KB Output is correct
17 Correct 3 ms 1144 KB Output is correct
18 Correct 3 ms 1144 KB Output is correct
19 Correct 3 ms 1144 KB Output is correct
20 Correct 3 ms 1020 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1144 KB Output is correct
23 Correct 3 ms 1144 KB Output is correct
24 Correct 4 ms 1144 KB Output is correct
25 Correct 4 ms 1144 KB Output is correct
26 Correct 4 ms 1144 KB Output is correct
27 Correct 4 ms 1144 KB Output is correct
28 Correct 3 ms 1144 KB Output is correct
29 Correct 3 ms 1016 KB Output is correct
30 Correct 4 ms 1144 KB Output is correct
31 Correct 3 ms 1144 KB Output is correct
32 Correct 3 ms 1144 KB Output is correct
33 Correct 7 ms 1272 KB Output is correct
34 Correct 15 ms 1148 KB Output is correct
35 Correct 67 ms 1144 KB Output is correct
36 Correct 74 ms 1144 KB Output is correct
37 Correct 81 ms 1144 KB Output is correct
38 Correct 13 ms 1144 KB Output is correct
39 Correct 27 ms 1144 KB Output is correct
40 Correct 34 ms 1144 KB Output is correct