Pool
시간 제한3초메모리 제한1024 MB
너비 N, 높이 1001인 격자에서 각 칸이 확률 q로 독립적으로 안전할 때, 해변에 붙은 가장 큰 안전 직사각형의 넓이가 정확히 K일 확률을 소수로 나눈 나머지를 구한다.
문제
There is a pool that can be modeled as a rectangular grid with width meters and height 1001 meters. The bottom edge of the grid corresponds to a beach. Each square cell of the grid represents a unit of sea.
A safe area for swimming shall satisfy the following constraints:
- All cells in the pool are safe.
- Must be rectangular.
- Must be adjacent to the bottom edge (i.e. the beach).
Given that each square cell of has probability to be safe (independently), and probability to be not safe, find the probability such that the largest safe area for swimming is exactly .
입력
Input a line with four positive integers where . The parameter is just .
출력
Output a line with an integer denoting the answer modulo 998244353: if the answer is in reduced form (i.e. and are coprime), then output such that and .
제한
힌트
where is prime and .