이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define N 200030
#define mod 1000000007
using namespace std;
typedef long long ll;
ll n, m, ans, pot[N], fat[N];
ll Pow(ll x, ll p)
{
if(!p) return 1LL;
ll ans = Pow(x, p/2);
ans = (ans*ans)%mod;
if(p & 1) return (ans*x)%mod;
return ans;
}
ll inverse(ll x){
return Pow(x, mod - 2)%mod;
}
ll Choose(ll a, ll b)
{
ll B = (fat[b]*fat[a - b])%mod;
return (fat[a]*inverse(B))%mod;
}
int32_t main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>m;
pot[0] = fat[0] = 1;
m--;
for(int i = 1; i < N; i++) fat[i] = (i*fat[i - 1])%mod;
for(int k = 0; k <= m + 1; k++)
{
ll sign = (k%2 == 0 ? 1 : -1);
ans = (ans + ((sign*Choose(n + 1, k)*Pow(m + 1 - k, n))%mod) )%mod;
}
cout<<(mod + ans)%mod<<'\n';
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |