弱校联盟 2015-10-1 E

时间:2022-12-22 10:21:39

E. Rectangle

Time Limit: 1000ms
Memory Limit: 65536KB
64-bit integer IO format: %lld      Java class name: Main
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\).
 
 
弱校联盟 2015-10-1 E
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 \leq n, m \leq 5 \cdot 10^4, 0 \leq k \leq 10^9\)).

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
156256250062500000
有技巧的暴力题,暴力一条边的长度,那么另外一条边的情况就能算出来了。
 
#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;
}