# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
227421 | 2020-04-27T11:14:49 Z | MKopchev | Asceticism (JOI18_asceticism) | C++14 | 30 ms | 1152 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=1e5+42,mod=1e9+7; int n,m; int fact[nmax],inv[nmax]; int C(int a,int b) { return 1LL*fact[a]*inv[b]%mod*inv[a-b]%mod; } int my_pow(long long a,int b) { //cout<<"my_pow "<<a<<" "<<b<<" -> "; long long ret=1; while(b) { if(b%2)ret=ret*a%mod; b=b/2; a=a*a%mod; } //cout<<ret<<endl; return ret; } int main() { scanf("%i%i",&n,&m); m--; fact[0]=1; for(int i=1;i<=n+1;i++)fact[i]=1LL*fact[i-1]*i%mod; for(int i=0;i<=n+1;i++) inv[i]=my_pow(fact[i],mod-2); int outp=0; for(int k=0;k<=m;k++) { long long add=1; if(k%2)add=mod-1; add=add*C(n+1,k)%mod; add=add*my_pow(m+1-k,n)%mod; //cout<<k<<" -> "<<add<<endl; outp=(outp+add)%mod; } printf("%i\n",outp); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Correct | 6 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Correct | 6 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 256 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Correct | 6 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 256 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 256 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Correct | 6 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 256 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 256 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 21 ms | 1152 KB | Output is correct |
32 | Correct | 21 ms | 1152 KB | Output is correct |
33 | Correct | 21 ms | 1152 KB | Output is correct |
34 | Correct | 21 ms | 1152 KB | Output is correct |
35 | Correct | 27 ms | 1152 KB | Output is correct |
36 | Correct | 30 ms | 1152 KB | Output is correct |
37 | Correct | 29 ms | 1152 KB | Output is correct |
38 | Correct | 8 ms | 512 KB | Output is correct |
39 | Correct | 20 ms | 896 KB | Output is correct |
40 | Correct | 24 ms | 1152 KB | Output is correct |