Submission #19694

#TimeUsernameProblemLanguageResultExecution timeMemory
19694gs12117창문 (kriii4_C)C++98
0 / 100
0 ms16716 KiB
#include<stdio.h> long long int n,m; long long int dp[2001000]; long long int mod=1000000007; long long int mpow(long long int x,long long int y){ if(y==0)return 1; long long int r=mpow(x,y/2); r*=r; r%=mod; if(y%2==1){ r*=x; r%=mod; } return r; } long long int minv(long long int x){ return mpow(x,mod-2); } int main(){ long long int i; long long int cat; scanf("%lld%lld",&n,&m); dp[0]=1; cat=1; for(i=0;i<n;i++){ dp[i+1]=dp[i]*(m+1); dp[i+1]%=mod; if(i%2==0){ dp[i+1]+=mod-cat; dp[i+1]%=mod; cat*=i+1; cat%=mod; cat*=i+2; cat%=mod; cat*=minv(i/2+1); cat%=mod; cat*=minv(i/2+2); cat%=mod; cat*=m; cat%=mod; } } printf("%lld",dp[n]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...