Submission #19588

#TimeUsernameProblemLanguageResultExecution timeMemory
19588gs12117Ω (kriii4_P3)C++98
100 / 100
0 ms1084 KiB
#include<stdio.h> int mod=1000000007; int p,q,n,m; int a[110]; int b[110]; long long int f(long long int x,long long int y){ if(y==0)return 1; long long int r=f(x,y/2); r*=r; r%=mod; if(y%2==0)return r; r*=x; r%=mod; return r; } int main(){ int i; long long int res=0; scanf("%d%d%d%d",&p,&q,&n,&m); p=(p-q)*f(p,mod-2)%mod; b[1]=p; for(i=1;i<n;i++){ b[i+1]=p*f(((long long int)b[i]*((p+mod-1)%mod)%mod+1)%mod,mod-2)%mod; } a[n]=1; for(i=n-1;i>0;i--){ a[i]=(long long int)a[i+1]*b[i]%mod; } a[0]=0; printf("%d\n",a[m]); }
#Verdict Execution timeMemoryGrader output
Fetching results...