Submission #20126

# Submission time Handle Problem Language Result Execution time Memory
20126 2016-02-27T04:54:54 Z progressive 로봇 (kriii4_F) C++14
4 / 100
1000 ms 1084 KB
#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
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
7 Correct 0 ms 1084 KB Output is correct
8 Correct 0 ms 1084 KB Output is correct
9 Correct 0 ms 1084 KB Output is correct
10 Correct 0 ms 1084 KB Output is correct
11 Correct 0 ms 1084 KB Output is correct
12 Correct 0 ms 1084 KB Output is correct
13 Correct 0 ms 1084 KB Output is correct
14 Correct 0 ms 1084 KB Output is correct
15 Correct 0 ms 1084 KB Output is correct
16 Correct 0 ms 1084 KB Output is correct
17 Correct 0 ms 1084 KB Output is correct
18 Correct 0 ms 1084 KB Output is correct
19 Correct 0 ms 1084 KB Output is correct
20 Correct 0 ms 1084 KB Output is correct
21 Correct 0 ms 1084 KB Output is correct
22 Correct 0 ms 1084 KB Output is correct
23 Correct 0 ms 1084 KB Output is correct
24 Correct 0 ms 1084 KB Output is correct
25 Correct 0 ms 1084 KB Output is correct
26 Correct 0 ms 1084 KB Output is correct
27 Correct 0 ms 1084 KB Output is correct
28 Correct 0 ms 1084 KB Output is correct
29 Correct 0 ms 1084 KB Output is correct
30 Correct 0 ms 1084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 1080 KB Program timed out
2 Halted 0 ms 0 KB -