1. 程式人生 > >Codeforces Round #517(Div2) A.Golden Plate

Codeforces Round #517(Div2) A.Golden Plate

A. Golden Plate

time limit per test1 second memory limit per test256 megabytes input:standard input output:standard output

You have a plate and you want to add some gilding to it. The plate is a rectangle that we split into w×h cells.There should be k gilded rings, the first one should go along the edge of the plate, the second one — 2 cells away from the edge and so on. Each ring has a width of 1 cell. Formally, the i-th of these rings should consist of all bordering cells on the inner rectangle of size (w−4(i−1))×(h−4(i−1)).

The picture corresponds to the third example.
Your task is to compute the number of cells to be gilded.

Input

The only line contains three integers w, h and k (3≤w,h≤100, 1≤k≤⌊min(n,m)+14⌋, where ⌊x⌋ denotes the number x rounded down) — the number of rows, columns and the number of rings, respectively.

Output

Print a single positive integer — the number of cells to be gilded.

Examples

input

3 3 1

output

8

input

7 9 1

output

28

input

7 9 2

output

40

Note

The first example is shown on the picture below.

The second example is shown on the picture below.

The third example is shown in the problem description.

題解

題目大意是給一個 寬X長 的一個矩形,從最外圍開始鋪 “金磚” ,最外圍作為第一層,如果還有第二層,則從寬為 w-4(i-1), 長為 h-4(i-1) (i>1)的矩形的最外層開始鋪,問能有多少 “金磚”。
仔細觀察便可得到,當只鋪第一層時,總的 “金磚” 是 2(w-2) + 2h, 當鋪第二層時,第二層鋪的“金磚”是在原先的 w 和 h 的基礎上減 4 後再應用上述公式,所以很容易就能得到程式碼。在 w 和 h 大於 0 的條件下應用 k 次上述公式並求和就可得出答案。程式碼如下:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
#define ll long long

using namespace std ;

int main(){
    int w , h , k ;
    cin >> w >> h >> k ;
    int ans = 0 ;
    while ( k -- ){
        ans += 2 * (w - 2) + 2 * h ;
        w -= 4 ;
        h -= 4 ;
        if ( w <= 0 || h <= 0 ){
            break ;
        }
    }
    cout << ans << endl ;
    return 0 ;
}