https://vjudge.net/contest/225393#problem/E
Rectangle
frog has a piece of paper divided into nn rows and mm columns. Today, she would like to draw a rectangle whose perimeter is not greater than kk.
Find the number of ways of drawing.
Input
The input consists of multiple tests. For each test:
The first line contains 33 integer n,m,kn,m,k (1≤n,m≤5⋅104,0≤k≤1091≤n,m≤5⋅104,0≤k≤109).
Output
For each test, write 11 integer which denotes the number of ways of drawing.
Sample Input
2 2 6
1 1 0
50000 50000 1000000000
Sample Output
8
0
1562562500625000000
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m, k;
while ( ~scanf ( "%d%d%d", &n, &m, &k ) )
{
long long a[100005] = { 0 };
for ( int i = 1; i <= m; i++ )
a[i] = a[i - 1] + m - i + 1 ;
//宽为 i 时,在 m 列中可能性为 m-i+1 种
// a[i] = (宽<= i) 时的总情况数
long long t = 0;
long long ans = 0;
for ( int j = 1; j <= n; j++ )
{
int q = min ( k / 2 - j, m );
//min(可达到的宽度,格子数)
if ( q < 0 ) q = 0;
//宽为j时不存在
t += a[q]; //j时的情况数
ans += t; //总情况数
}
printf ( "%lld\n", ans );
}
return 0;
}