codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

40B.md (1111B)


      1 Source: https://codeforces.com/problemset/problem/40/B
      2 
      3 B. Repaintings
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 A chessboard *n* × *m* in size is given. During the zero minute we repaint all the black squares to the 0 color. During the *i*-th minute we repaint to the *i* color the initially black squares that have exactly four corner-adjacent squares painted *i* - 1 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly *x* times.
     22 
     23 The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.
     24 
     25 Input
     26 
     27 The first line contains integers *n* and *m* (1 ≤ *n*, *m* ≤ 5000). The second line contains integer *x* (1 ≤ *x* ≤ 109).
     28 
     29 Output
     30 
     31 Print how many squares will be painted exactly *x* times.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 3 3  
     39 1
     40 ```
     41 
     42 Output
     43 
     44 ```
     45 4
     46 ```
     47 
     48 Input
     49 
     50 ```
     51 3 3  
     52 2
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 1
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 1 1  
     65 1
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 1
     72 ```