# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
49058 | 2018-05-21T14:46:44 Z | Namnamseo | Asceticism (JOI18_asceticism) | C++17 | 49 ms | 2572 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pp; typedef pair<ll,ll> pll; void read(int& x){ scanf("%d",&x); } void read(ll& x){ scanf("%lld",&x); } template<typename T,typename... Args> void read(T& a,Args&... b){ read(a); read(b...); } #define all(x) (x).begin(),(x).end() #define pb push_back #define eb emplace_back #define x first #define y second int n, k; const ll mod = 1'000'000'007; ll fact[200001]; ll Pow(ll b, ll e){ ll ret=1; while(e){ if(e&1) (ret*=b)%=mod; e/=2; (b*=b)%=mod; } return ret; } ll Comb(ll n, ll r){ if(r<0 || r>n) return 0; return fact[n]*Pow(fact[r], mod-2)%mod*Pow(fact[n-r], mod-2)%mod; } int main() { fact[0]=1; for(int i=1; i<=200000; ++i) fact[i]=fact[i-1]*i%mod; int n, k; cin >> n >> k; --k; ll ans = 0; for(int j=0; j<=k; ++j){ (ans += ((j%2?-1:1)*Comb(n+1, j)*Pow(k-j+1, n)%mod+mod)%mod) %= mod; } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2040 KB | Output is correct |
2 | Correct | 4 ms | 2152 KB | Output is correct |
3 | Correct | 5 ms | 2152 KB | Output is correct |
4 | Correct | 5 ms | 2152 KB | Output is correct |
5 | Correct | 5 ms | 2208 KB | Output is correct |
6 | Correct | 5 ms | 2340 KB | Output is correct |
7 | Correct | 4 ms | 2340 KB | Output is correct |
8 | Correct | 4 ms | 2340 KB | Output is correct |
9 | Correct | 5 ms | 2388 KB | Output is correct |
10 | Correct | 5 ms | 2388 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2040 KB | Output is correct |
2 | Correct | 4 ms | 2152 KB | Output is correct |
3 | Correct | 5 ms | 2152 KB | Output is correct |
4 | Correct | 5 ms | 2152 KB | Output is correct |
5 | Correct | 5 ms | 2208 KB | Output is correct |
6 | Correct | 5 ms | 2340 KB | Output is correct |
7 | Correct | 4 ms | 2340 KB | Output is correct |
8 | Correct | 4 ms | 2340 KB | Output is correct |
9 | Correct | 5 ms | 2388 KB | Output is correct |
10 | Correct | 5 ms | 2388 KB | Output is correct |
11 | Correct | 4 ms | 2388 KB | Output is correct |
12 | Correct | 4 ms | 2388 KB | Output is correct |
13 | Correct | 4 ms | 2388 KB | Output is correct |
14 | Correct | 5 ms | 2388 KB | Output is correct |
15 | Correct | 5 ms | 2508 KB | Output is correct |
16 | Correct | 4 ms | 2508 KB | Output is correct |
17 | Correct | 4 ms | 2572 KB | Output is correct |
18 | Correct | 5 ms | 2572 KB | Output is correct |
19 | Correct | 5 ms | 2572 KB | Output is correct |
20 | Correct | 5 ms | 2572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2040 KB | Output is correct |
2 | Correct | 4 ms | 2152 KB | Output is correct |
3 | Correct | 5 ms | 2152 KB | Output is correct |
4 | Correct | 5 ms | 2152 KB | Output is correct |
5 | Correct | 5 ms | 2208 KB | Output is correct |
6 | Correct | 5 ms | 2340 KB | Output is correct |
7 | Correct | 4 ms | 2340 KB | Output is correct |
8 | Correct | 4 ms | 2340 KB | Output is correct |
9 | Correct | 5 ms | 2388 KB | Output is correct |
10 | Correct | 5 ms | 2388 KB | Output is correct |
11 | Correct | 4 ms | 2388 KB | Output is correct |
12 | Correct | 4 ms | 2388 KB | Output is correct |
13 | Correct | 4 ms | 2388 KB | Output is correct |
14 | Correct | 5 ms | 2388 KB | Output is correct |
15 | Correct | 5 ms | 2508 KB | Output is correct |
16 | Correct | 4 ms | 2508 KB | Output is correct |
17 | Correct | 4 ms | 2572 KB | Output is correct |
18 | Correct | 5 ms | 2572 KB | Output is correct |
19 | Correct | 5 ms | 2572 KB | Output is correct |
20 | Correct | 5 ms | 2572 KB | Output is correct |
21 | Correct | 6 ms | 2572 KB | Output is correct |
22 | Correct | 5 ms | 2572 KB | Output is correct |
23 | Correct | 5 ms | 2572 KB | Output is correct |
24 | Correct | 5 ms | 2572 KB | Output is correct |
25 | Correct | 5 ms | 2572 KB | Output is correct |
26 | Correct | 6 ms | 2572 KB | Output is correct |
27 | Correct | 6 ms | 2572 KB | Output is correct |
28 | Correct | 5 ms | 2572 KB | Output is correct |
29 | Correct | 4 ms | 2572 KB | Output is correct |
30 | Correct | 5 ms | 2572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2040 KB | Output is correct |
2 | Correct | 4 ms | 2152 KB | Output is correct |
3 | Correct | 5 ms | 2152 KB | Output is correct |
4 | Correct | 5 ms | 2152 KB | Output is correct |
5 | Correct | 5 ms | 2208 KB | Output is correct |
6 | Correct | 5 ms | 2340 KB | Output is correct |
7 | Correct | 4 ms | 2340 KB | Output is correct |
8 | Correct | 4 ms | 2340 KB | Output is correct |
9 | Correct | 5 ms | 2388 KB | Output is correct |
10 | Correct | 5 ms | 2388 KB | Output is correct |
11 | Correct | 4 ms | 2388 KB | Output is correct |
12 | Correct | 4 ms | 2388 KB | Output is correct |
13 | Correct | 4 ms | 2388 KB | Output is correct |
14 | Correct | 5 ms | 2388 KB | Output is correct |
15 | Correct | 5 ms | 2508 KB | Output is correct |
16 | Correct | 4 ms | 2508 KB | Output is correct |
17 | Correct | 4 ms | 2572 KB | Output is correct |
18 | Correct | 5 ms | 2572 KB | Output is correct |
19 | Correct | 5 ms | 2572 KB | Output is correct |
20 | Correct | 5 ms | 2572 KB | Output is correct |
21 | Correct | 6 ms | 2572 KB | Output is correct |
22 | Correct | 5 ms | 2572 KB | Output is correct |
23 | Correct | 5 ms | 2572 KB | Output is correct |
24 | Correct | 5 ms | 2572 KB | Output is correct |
25 | Correct | 5 ms | 2572 KB | Output is correct |
26 | Correct | 6 ms | 2572 KB | Output is correct |
27 | Correct | 6 ms | 2572 KB | Output is correct |
28 | Correct | 5 ms | 2572 KB | Output is correct |
29 | Correct | 4 ms | 2572 KB | Output is correct |
30 | Correct | 5 ms | 2572 KB | Output is correct |
31 | Correct | 4 ms | 2572 KB | Output is correct |
32 | Correct | 5 ms | 2572 KB | Output is correct |
33 | Correct | 6 ms | 2572 KB | Output is correct |
34 | Correct | 13 ms | 2572 KB | Output is correct |
35 | Correct | 42 ms | 2572 KB | Output is correct |
36 | Correct | 48 ms | 2572 KB | Output is correct |
37 | Correct | 49 ms | 2572 KB | Output is correct |
38 | Correct | 11 ms | 2572 KB | Output is correct |
39 | Correct | 20 ms | 2572 KB | Output is correct |
40 | Correct | 24 ms | 2572 KB | Output is correct |