当前位置:首页 » 其他

Rectangle

2015-10-11 11:23 本站整理 浏览(11)

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.

InputThe 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).

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

Sample Input2 2 6

1 1 0

50000 50000 1000000000

Sample Output8

0

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

以下是代码:

[code]#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;  
}