Submission #20061

# Submission time Handle Problem Language Result Execution time Memory
20061 2016-02-25T08:58:32 Z gs13068 로봇 (kriii4_F) C++
0 / 100
1000 ms 1084 KB
#include <cstdio>

const int p = 1000000007;

using namespace std;

int f(int x, int y)
{
	return y & 1 ? (long long)f(x, y ^ 1)*x%p : y ? f((long long)x*x%p, y >> 1) : 1;
}

int px[4] = { 1,0,-1,0 };
int py[4] = { 0,1,0,-1 };

int L, R, M;

int g(int n, int x, int y, int z)
{
	if (n == 0) return x*x + y*y;
	int a = (long long)g(n - 1, x + px[z], y + py[z], z) * M % p;
	z = z + 1 & 3;
	int b = (long long)g(n - 1, x + px[z], y + py[z], z) * L % p;
	z = z + 2 & 3;
	int c = (long long)g(n - 1, x + px[z], y + py[z], z) * R % p;
	return ((long long)a + b + c) * f(L + R + M, p - 2) % p;
}

int main()
{
	int n;
	scanf("%d%d%d%d", &n, &L, &M, &R);
	printf("%d", g(n, 0, 0, 0));
}
# Verdict Execution time Memory Grader output
1 Correct 33 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 97 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 97 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 291 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 93 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 97 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 11 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 32 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 32 ms 1084 KB Output is correct
29 Correct 873 ms 1084 KB Output is correct
30 Execution timed out 1000 ms 1080 KB Program timed out
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -