#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 1000000007
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 100003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
long long fak[mx],inv[mx],n,k;
long long C(int n,int k){
long long ret=fak[n]*inv[k]%MOD;
ret=ret*inv[n-k]%MOD;
return ret;
}
long long pow_(long long a,int b){
if(b==0)return 1;
long long sem=pow_(a,b/2);
sem=(sem*sem)%MOD;
if(b&1)sem=(sem*a)%MOD;
return sem;
}
int main(){
fak[1]=inv[1]=inv[0]=inv[1]=1;
for(int i=2;i<=1e5+5;i++){
fak[i]=fak[i-1]*i%MOD;
inv[i]=(MOD-1LL*(MOD/i)*inv[MOD%i]%MOD)%MOD;
}
for(int i=1;i<=1e5+5;i++){
inv[i]=inv[i]*inv[i-1]%MOD;
}
long long m;
cin>>n>>m;
long long jaw=0;
m--;
for(int k=0;k<=m;k++){
long long sem;
sem=C(n+1,k)*pow_(m+1-k,n)%MOD;
if(k&1){
sem=(MOD-sem)%MOD;
}
jaw=(jaw+sem)%MOD;
}
cout<<jaw<<endl;
}
Compilation message
asceticism.cpp: In function 'int main()':
asceticism.cpp:37:15: warning: operation on 'inv[1]' may be undefined [-Wsequence-point]
fak[1]=inv[1]=inv[0]=inv[1]=1;
~~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1784 KB |
Output is correct |
2 |
Correct |
9 ms |
2020 KB |
Output is correct |
3 |
Correct |
7 ms |
2032 KB |
Output is correct |
4 |
Correct |
6 ms |
2032 KB |
Output is correct |
5 |
Correct |
8 ms |
2032 KB |
Output is correct |
6 |
Correct |
7 ms |
2180 KB |
Output is correct |
7 |
Correct |
6 ms |
2180 KB |
Output is correct |
8 |
Correct |
5 ms |
2180 KB |
Output is correct |
9 |
Correct |
6 ms |
2180 KB |
Output is correct |
10 |
Correct |
6 ms |
2180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1784 KB |
Output is correct |
2 |
Correct |
9 ms |
2020 KB |
Output is correct |
3 |
Correct |
7 ms |
2032 KB |
Output is correct |
4 |
Correct |
6 ms |
2032 KB |
Output is correct |
5 |
Correct |
8 ms |
2032 KB |
Output is correct |
6 |
Correct |
7 ms |
2180 KB |
Output is correct |
7 |
Correct |
6 ms |
2180 KB |
Output is correct |
8 |
Correct |
5 ms |
2180 KB |
Output is correct |
9 |
Correct |
6 ms |
2180 KB |
Output is correct |
10 |
Correct |
6 ms |
2180 KB |
Output is correct |
11 |
Correct |
6 ms |
2180 KB |
Output is correct |
12 |
Correct |
8 ms |
2180 KB |
Output is correct |
13 |
Correct |
6 ms |
2180 KB |
Output is correct |
14 |
Correct |
6 ms |
2180 KB |
Output is correct |
15 |
Correct |
7 ms |
2180 KB |
Output is correct |
16 |
Correct |
6 ms |
2180 KB |
Output is correct |
17 |
Correct |
7 ms |
2180 KB |
Output is correct |
18 |
Correct |
8 ms |
2180 KB |
Output is correct |
19 |
Correct |
7 ms |
2180 KB |
Output is correct |
20 |
Correct |
8 ms |
2180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1784 KB |
Output is correct |
2 |
Correct |
9 ms |
2020 KB |
Output is correct |
3 |
Correct |
7 ms |
2032 KB |
Output is correct |
4 |
Correct |
6 ms |
2032 KB |
Output is correct |
5 |
Correct |
8 ms |
2032 KB |
Output is correct |
6 |
Correct |
7 ms |
2180 KB |
Output is correct |
7 |
Correct |
6 ms |
2180 KB |
Output is correct |
8 |
Correct |
5 ms |
2180 KB |
Output is correct |
9 |
Correct |
6 ms |
2180 KB |
Output is correct |
10 |
Correct |
6 ms |
2180 KB |
Output is correct |
11 |
Correct |
6 ms |
2180 KB |
Output is correct |
12 |
Correct |
8 ms |
2180 KB |
Output is correct |
13 |
Correct |
6 ms |
2180 KB |
Output is correct |
14 |
Correct |
6 ms |
2180 KB |
Output is correct |
15 |
Correct |
7 ms |
2180 KB |
Output is correct |
16 |
Correct |
6 ms |
2180 KB |
Output is correct |
17 |
Correct |
7 ms |
2180 KB |
Output is correct |
18 |
Correct |
8 ms |
2180 KB |
Output is correct |
19 |
Correct |
7 ms |
2180 KB |
Output is correct |
20 |
Correct |
8 ms |
2180 KB |
Output is correct |
21 |
Correct |
7 ms |
2180 KB |
Output is correct |
22 |
Correct |
7 ms |
2180 KB |
Output is correct |
23 |
Correct |
8 ms |
2180 KB |
Output is correct |
24 |
Correct |
10 ms |
2180 KB |
Output is correct |
25 |
Correct |
8 ms |
2180 KB |
Output is correct |
26 |
Correct |
8 ms |
2180 KB |
Output is correct |
27 |
Correct |
6 ms |
2180 KB |
Output is correct |
28 |
Correct |
7 ms |
2180 KB |
Output is correct |
29 |
Correct |
9 ms |
2180 KB |
Output is correct |
30 |
Correct |
9 ms |
2180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1784 KB |
Output is correct |
2 |
Correct |
9 ms |
2020 KB |
Output is correct |
3 |
Correct |
7 ms |
2032 KB |
Output is correct |
4 |
Correct |
6 ms |
2032 KB |
Output is correct |
5 |
Correct |
8 ms |
2032 KB |
Output is correct |
6 |
Correct |
7 ms |
2180 KB |
Output is correct |
7 |
Correct |
6 ms |
2180 KB |
Output is correct |
8 |
Correct |
5 ms |
2180 KB |
Output is correct |
9 |
Correct |
6 ms |
2180 KB |
Output is correct |
10 |
Correct |
6 ms |
2180 KB |
Output is correct |
11 |
Correct |
6 ms |
2180 KB |
Output is correct |
12 |
Correct |
8 ms |
2180 KB |
Output is correct |
13 |
Correct |
6 ms |
2180 KB |
Output is correct |
14 |
Correct |
6 ms |
2180 KB |
Output is correct |
15 |
Correct |
7 ms |
2180 KB |
Output is correct |
16 |
Correct |
6 ms |
2180 KB |
Output is correct |
17 |
Correct |
7 ms |
2180 KB |
Output is correct |
18 |
Correct |
8 ms |
2180 KB |
Output is correct |
19 |
Correct |
7 ms |
2180 KB |
Output is correct |
20 |
Correct |
8 ms |
2180 KB |
Output is correct |
21 |
Correct |
7 ms |
2180 KB |
Output is correct |
22 |
Correct |
7 ms |
2180 KB |
Output is correct |
23 |
Correct |
8 ms |
2180 KB |
Output is correct |
24 |
Correct |
10 ms |
2180 KB |
Output is correct |
25 |
Correct |
8 ms |
2180 KB |
Output is correct |
26 |
Correct |
8 ms |
2180 KB |
Output is correct |
27 |
Correct |
6 ms |
2180 KB |
Output is correct |
28 |
Correct |
7 ms |
2180 KB |
Output is correct |
29 |
Correct |
9 ms |
2180 KB |
Output is correct |
30 |
Correct |
9 ms |
2180 KB |
Output is correct |
31 |
Correct |
6 ms |
2180 KB |
Output is correct |
32 |
Correct |
8 ms |
2180 KB |
Output is correct |
33 |
Correct |
8 ms |
2180 KB |
Output is correct |
34 |
Correct |
9 ms |
2264 KB |
Output is correct |
35 |
Correct |
22 ms |
2264 KB |
Output is correct |
36 |
Correct |
28 ms |
2328 KB |
Output is correct |
37 |
Correct |
29 ms |
2328 KB |
Output is correct |
38 |
Correct |
9 ms |
2328 KB |
Output is correct |
39 |
Correct |
12 ms |
2328 KB |
Output is correct |
40 |
Correct |
15 ms |
2328 KB |
Output is correct |