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;
#define ll long long
const int maxn=1e5+7;
ll n,m,k;
ll a[maxn];
int main()
{
while(~scanf("%lld%lld%lld",&n,&m,&k))
{
for(int i=1;i<=m;i++)a[i]=a[i-1]+m-i+1;
ll t=0,ans=0;
for(ll i=1;i<=n;i++)
{
ll id=min((k-2*i)/2,m);
if(id<0)id=0;
t+=a[id];
ans+=t;
}
printf("%lld\n",ans);
}
return 0;
}