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<cstdio>
const int MOD = 1000000007;
long long powM(long long a, long long b)
{
if(b==1) return a;
if(b%2==1) return a*powM(a,b-1)%MOD;
return powM(a,b/2)*powM(a,b/2)%MOD;
}
int main()
{
long long sum_xi = 0;
long long sum_yi = 0;
long long sum_square = 0;
long long LMRN = 1;
int N, L, M, R;
scanf("%d%d%d%d",&N,&L,&M,&R);
for(int i=0; i<N; i++)
{
LMRN = LMRN*(L+M+R)%MOD;
long long new_xi = (((L-R)*sum_yi+M*sum_xi+LMRN)%MOD+MOD)%MOD;
long long new_yi = (((R-L)*sum_xi+M*sum_yi)%MOD+MOD)%MOD;
long long new_square = (((L+M+R)*sum_square+LMRN+2*(L-R)*sum_yi + 2*M*sum_xi)%MOD+MOD)%MOD;
sum_xi = new_xi;
sum_yi = new_yi;
sum_square = new_square;
}
printf("%lld",sum_square*powM(LMRN,MOD-2)%MOD);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |