scanf/printf
, you have to write fflush(stdout)
.$H \ W \ N \ K$
$? \ a \ b \ c \ d$It means that you want to ask the number of bombs in the rectangular area which upper-left cell is $(a, b)$ and lower-right cell is $(c, d)$.
$p$$p$ is the result of your question.
$! \ ans$The value of $ans$ is $\sum_{i=0}^{H-1} \sum_{j=0}^{W-1} r_{i, j} 2^{iW + j}$ mod $K$. Note: $r_{i, j}$ is the number of bombs in cell $(i, j)$.
H=4, W=4, N=4 1001 0000 0010 0100Example of Input・Output
Input from program | Output |
---|---|
4 4 4 1000000007 | |
? 0 0 0 1 | |
1 | |
? 0 1 0 2 | |
0 | |
? 0 3 1 3 | |
1 | |
? 2 1 3 2 | |
2 | |
? 2 2 2 2 | |
1 | |
! 9225 |