Submission #20061

#TimeUsernameProblemLanguageResultExecution timeMemory
20061gs13068로봇 (kriii4_F)C++98
0 / 100
1000 ms1084 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...