#P6429. [COCI 2008/2009 #1] JEZ
[COCI 2008/2009 #1] JEZ
Description
There is a rectangle of height and width , divided into small rectangles.
Rows are numbered from top to bottom from to , and columns are numbered from left to right from to .
Each small rectangle has a color. If a small rectangle is at row and column , then:
- If , this rectangle is gray.
- Otherwise, it is white.
The lower-left figure shows the case :

Now someone walks steps along the path shown in the upper-right figure on this rectangle. Find how many gray cells they step on.
Input Format
The first line contains two integers and .
The second line contains one integer .
Output Format
Output one line containing the number of gray cells they step on.
10 10
6
5
3 5
11
8
10 10
100
51
Hint
Constraints
- For of the testdata, is guaranteed.
- For of the testdata, , , and the answer fits in a -bit integer.
Notes:
This problem is translated from COCI2008-2009 CONTEST #1 JEZ. Translator: @菜鸟一只。
Translated by ChatGPT 5
京公网安备 11011102002149号