Http://codeforces.com/problemset/problem/215/C
I have been thinking about it for a long time, but I don't know why there are only four in. After reading the hint of the original CF question, I don't know why the four are. Later, I finally understood. The two equations are very important. I did not understand the meaning of these two equations when I typed the code, so I couldn't go through it.
After reading other people's code and understanding it for a long time, you can understand it.
First, any one of these two equations can represent a rectangle (the cross can be wide ). With this in mind, the code should be no more than ten.
Let's enumerate a rectangle (the side must be an odd number). If this rectangle meets the conditions, we can enumerate the length (or width) of another rectangle (because the total area has been set ).
I really cannot afford to hurt the question of CF. I did it today from last night...
#include <cstdio>int n,m,s,r;//2 equations represents 2 rectangles!!!//so we enumerate one rectangle's hight and width//how many rectangle with h and m are there in the big given rectangle__int64 f(int h,int w){ return (n - h + 1) * (m - w + 1 );}__int64 ans;int main(){ scanf("%d%d%d",&n,&m,&s); ans = 0; for(int i = 1; i <= n; i += 2){//enumerate hight for(int j = 1; j <= m && (r = s - i * j) >= 0; j += 2){ if(r == 0){//one rectangle is fairly enough //suppose (a,b) must be i,j //then (c,d) can have (i + 1)/2 * (j + 1)/2 choices //then (a,b) and (c,d) can exchange, so we * 2 //but if(a,b) and (c,d) are the same,exchange them does not make any difference //that is when a = c = i, b = d = j ans +=( (i + 1) * (j + 1) / 2 - 1) * f(i,j); }else for(int k = 1; k < j; k += 2) if(r % (2 * k) == 0 && i + r / k <= n) ans += 2 * f(i + r / k, j);// (a,b) and (c,d) can exchange } } printf("%I64d\n",ans); return 0;}