Submission #20126

#TimeUsernameProblemLanguageResultExecution timeMemory
20126progressive로봇 (kriii4_F)C++14
4 / 100
1000 ms1084 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...