// long long int 未使用版 #include int m(int x, int y, int r) { int e = 1 << 15; int a = x / e, b = x % e; int c = y / e, d = y % e; int X = a * c % r; int Y = (a * d + b * c) % r; int Z = b * d % r; for(int i = 0; i < 15; i++) { X *= 2; X %= r; X *= 2; X %= r; Y *= 2; Y %= r; } return ((X + Y) % r + Z) % r; } int main() { unsigned int a, b, c, d; scanf("%u%u%u%u", &a, &b, &c, &d); printf("%d\n", m( m(a, b, d), c, d) ); return 0; }