# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19588 | gs12117 | Ω (kriii4_P3) | C++98 | 0 ms | 1084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |