답안 #968580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968580 2024-04-23T16:12:36 Z Tuanlinh123 Asceticism (JOI18_asceticism) C++17
100 / 100
9 ms 2164 KB
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;

const ll maxn=100005, Mod=1e9+7;
ll po[maxn], inv[maxn];
ll C(ll k, ll n){return po[n]*inv[k]%Mod*inv[n-k]%Mod;}

ll binpow(ll a, ll k)
{
    ll ans=1;
    for (; k; a=a*a%Mod, k>>=1)
        if (k&1) ans=ans*a%Mod;
    return ans;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n, k; cin >> n >> k;
    for (ll i=0; i<maxn; i++)
        po[i]=i?po[i-1]*i%Mod:1;
    inv[maxn-1]=binpow(po[maxn-1], Mod-2);
    for (ll i=maxn-2; i>=0; i--)
        inv[i]=inv[i+1]*(i+1)%Mod;
    ll ans=0;
    for (ll i=0; i<k; i++)
        ans+=(i&1?-1:1)*C(i, n+1)*binpow(k-i, n)%Mod;
    cout << (ans%Mod+Mod)%Mod;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 3 ms 1884 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 1884 KB Output is correct
9 Correct 2 ms 1884 KB Output is correct
10 Correct 2 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 3 ms 1884 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 1884 KB Output is correct
9 Correct 2 ms 1884 KB Output is correct
10 Correct 2 ms 1884 KB Output is correct
11 Correct 2 ms 1884 KB Output is correct
12 Correct 2 ms 1884 KB Output is correct
13 Correct 2 ms 1884 KB Output is correct
14 Correct 2 ms 1884 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1876 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 2020 KB Output is correct
20 Correct 3 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 3 ms 1884 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 1884 KB Output is correct
9 Correct 2 ms 1884 KB Output is correct
10 Correct 2 ms 1884 KB Output is correct
11 Correct 2 ms 1884 KB Output is correct
12 Correct 2 ms 1884 KB Output is correct
13 Correct 2 ms 1884 KB Output is correct
14 Correct 2 ms 1884 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1876 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 2020 KB Output is correct
20 Correct 3 ms 1884 KB Output is correct
21 Correct 2 ms 1884 KB Output is correct
22 Correct 2 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 2 ms 1884 KB Output is correct
25 Correct 3 ms 1884 KB Output is correct
26 Correct 2 ms 1884 KB Output is correct
27 Correct 2 ms 1884 KB Output is correct
28 Correct 2 ms 1884 KB Output is correct
29 Correct 2 ms 1884 KB Output is correct
30 Correct 2 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 3 ms 1884 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 1884 KB Output is correct
9 Correct 2 ms 1884 KB Output is correct
10 Correct 2 ms 1884 KB Output is correct
11 Correct 2 ms 1884 KB Output is correct
12 Correct 2 ms 1884 KB Output is correct
13 Correct 2 ms 1884 KB Output is correct
14 Correct 2 ms 1884 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1876 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 2020 KB Output is correct
20 Correct 3 ms 1884 KB Output is correct
21 Correct 2 ms 1884 KB Output is correct
22 Correct 2 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 2 ms 1884 KB Output is correct
25 Correct 3 ms 1884 KB Output is correct
26 Correct 2 ms 1884 KB Output is correct
27 Correct 2 ms 1884 KB Output is correct
28 Correct 2 ms 1884 KB Output is correct
29 Correct 2 ms 1884 KB Output is correct
30 Correct 2 ms 1884 KB Output is correct
31 Correct 2 ms 2136 KB Output is correct
32 Correct 2 ms 2000 KB Output is correct
33 Correct 3 ms 1884 KB Output is correct
34 Correct 3 ms 1884 KB Output is correct
35 Correct 8 ms 2024 KB Output is correct
36 Correct 8 ms 2024 KB Output is correct
37 Correct 9 ms 1884 KB Output is correct
38 Correct 3 ms 1884 KB Output is correct
39 Correct 4 ms 1884 KB Output is correct
40 Correct 5 ms 2164 KB Output is correct