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.
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
1562562500625000000
求在NXM的方格中,能画出多少个周长不超过K的矩形。
从第1行到第N行递推,记录每行可行的个数相加。
#include <stdio.h>
#include <climits>
#include <cstring>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <vector>
#include <string>
#define INF 0x3f3f3f3f
#define ll long long
#define Pair pair<int,int>
#define re return
#define getLen(name,index) name[index].size()
#define mem(a,b) memset(a,b,sizeof(a))
#define Make(a,b) make_pair(a,b)
#define Push(num) push_back(num)
#define rep(index,star,finish) for(register int index=star;index<finish;index++)
#define drep(index,finish,star) for(register int index=finish;index>=star;index--)
using namespace std;
const int maxn=5e4+5;
int N,M,K;
void dfs(int r);
ll dp[maxn];
int main(){
while(~scanf("%d%d%d",&N,&M,&K)){
ll sum=0;
ll lim=max(0,min(K/2-1,M));
mem(dp,0);
dp[1]=lim*(M+1)*1LL-(1+lim)*lim*1LL/2;
sum+=dp[1];
rep(i,2,N+1){
lim=max(0,min(K/2-i,M));
dp[i]=dp[i-1]+lim*(M+1)*1LL-(1+lim)*1LL*lim/2;
sum+=dp[i];
}
printf("%lld\n",sum);
}
re 0;
}