Submission #70029

# Submission time Handle Problem Language Result Execution time Memory
70029 2018-08-22T09:30:10 Z yogahmad Asceticism (JOI18_asceticism) C++14
4 / 100
8 ms 2300 KB
#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);
		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;
         ~~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1912 KB Output is correct
2 Correct 7 ms 1912 KB Output is correct
3 Correct 6 ms 1928 KB Output is correct
4 Correct 8 ms 2004 KB Output is correct
5 Correct 7 ms 2080 KB Output is correct
6 Correct 7 ms 2084 KB Output is correct
7 Correct 7 ms 2084 KB Output is correct
8 Correct 7 ms 2156 KB Output is correct
9 Correct 6 ms 2156 KB Output is correct
10 Correct 8 ms 2172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1912 KB Output is correct
2 Correct 7 ms 1912 KB Output is correct
3 Correct 6 ms 1928 KB Output is correct
4 Correct 8 ms 2004 KB Output is correct
5 Correct 7 ms 2080 KB Output is correct
6 Correct 7 ms 2084 KB Output is correct
7 Correct 7 ms 2084 KB Output is correct
8 Correct 7 ms 2156 KB Output is correct
9 Correct 6 ms 2156 KB Output is correct
10 Correct 8 ms 2172 KB Output is correct
11 Correct 6 ms 2172 KB Output is correct
12 Correct 7 ms 2172 KB Output is correct
13 Correct 6 ms 2172 KB Output is correct
14 Correct 6 ms 2172 KB Output is correct
15 Incorrect 8 ms 2300 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1912 KB Output is correct
2 Correct 7 ms 1912 KB Output is correct
3 Correct 6 ms 1928 KB Output is correct
4 Correct 8 ms 2004 KB Output is correct
5 Correct 7 ms 2080 KB Output is correct
6 Correct 7 ms 2084 KB Output is correct
7 Correct 7 ms 2084 KB Output is correct
8 Correct 7 ms 2156 KB Output is correct
9 Correct 6 ms 2156 KB Output is correct
10 Correct 8 ms 2172 KB Output is correct
11 Correct 6 ms 2172 KB Output is correct
12 Correct 7 ms 2172 KB Output is correct
13 Correct 6 ms 2172 KB Output is correct
14 Correct 6 ms 2172 KB Output is correct
15 Incorrect 8 ms 2300 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1912 KB Output is correct
2 Correct 7 ms 1912 KB Output is correct
3 Correct 6 ms 1928 KB Output is correct
4 Correct 8 ms 2004 KB Output is correct
5 Correct 7 ms 2080 KB Output is correct
6 Correct 7 ms 2084 KB Output is correct
7 Correct 7 ms 2084 KB Output is correct
8 Correct 7 ms 2156 KB Output is correct
9 Correct 6 ms 2156 KB Output is correct
10 Correct 8 ms 2172 KB Output is correct
11 Correct 6 ms 2172 KB Output is correct
12 Correct 7 ms 2172 KB Output is correct
13 Correct 6 ms 2172 KB Output is correct
14 Correct 6 ms 2172 KB Output is correct
15 Incorrect 8 ms 2300 KB Output isn't correct
16 Halted 0 ms 0 KB -