Rectangle

Rectangle

frog has a piece of paper divided into n rows and m columns. Today, she would like to draw a rectangle whose perimeter is not greater than k.
这里写图片描述
There are 8 (out of 9) ways when n = m = 2, k = 6
There are 8 (out of 9) ways when n=m=2,k=6

Find the number of ways of drawing.

Input

The input consists of multiple tests. For each test:

The first line contains 3 integer n,m,k (1≤n,m≤5⋅104,0≤k≤109).

Output

For each test, write 1 integer which denotes the number of ways of drawing.

Sample Input

2 2 6
1 1 0
50000 50000 1000000000

Sample Output

8
0

题目思路:暴力。枚举一条边,另一条边可以表示出来。

以下是代码:

#include<iostream> 
using namespace std;  
int main()  
{  
    long long n,m,k;  
    while(cin >> n >> m >> k)  
    {  
        k/=2;  
        long long ans = 0;  
        for(int i=1;i<=n&&k-i>0;i++)  
        {  
            long long j = min(k-i,m);  
            long long a = n-i+1;  
            long long b = (m+(m-j+1))*j/2;  
            ans+=a*b;  
        }  
        cout<<ans<<endl;  
    }  
    return 0;  
}  

你可能感兴趣的:(rectangle)