Luo Gu P1548 chessboard
- There are pictures and turn link title: title
answer:
- I'm not a math problem, then dp find the law fucks out ... ...
- Looking at the solution to a problem area dp did not come out of
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 105
using namespace std;
int n, m;
int f[maxn][maxn];
int main()
{
cin >> m >> n;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
f[i][j] = f[i - 1][j - 1] + i * j;
cout << f[n][m] << ' ';
memset(f, 0, sizeof(f));
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
f[i][j] = f[i - 1][j - 1] + i * j * (i + j - 2) / 2;
cout << f[n][m];
return 0;
}