Cod sursa(job #2631224)
Utilizator | Alexandru Peticaru Pety | Data | 29 iunie 2020 15:20:40 |
---|---|---|---|
Problema | Dreptunghiuri | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("dreptunghiuri.in");
ofstream fout ("dreptunghiuri.out");
long long n, m, ans;
int main()
{
fin >> n >> m;
long long ans = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
ans += (i - 1) * (j - 1);
for (int k = 1; k <= max(n, m); k++) {
if (j + k > m)
continue;
if (i - k < 1)
continue;
ans += min(i - k - 1, j - 1);
}
}
fout << ans;
return 0;
}