Cod sursa(job #1494599)

Utilizator akaprosAna Kapros akapros Data 1 octombrie 2015 15:32:22
Problema Dreptunghiuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxN 402
using namespace std;
int n, m, i, j;
long long sol;
void read()
{
    freopen("dreptunghiuri.in", "r", stdin);
    scanf("%d %d", &n, &m);
    sol = (n * (n - 1) *1LL) / 2;
    if (m % 2)
    {
        sol *= (m - 1) / 2 * 1LL;
        sol *= m * 1LL;
    }else
    {
        sol *= m / 2 * 1LL;
        sol *= (m - 1) * 1LL;
    }
}
void solve()
{
    int l, c;
    for (i = 1; i <= n; ++ i)
        for (j = 1; j <= m; ++ j)
    {
        l = min(n - i, i - 1);
        c = min(m - j, j - 1);
        sol += l * c * 1LL;
    }
}
void write()
{
    freopen("dreptunghiuri.out", "w", stdout);
    printf("%lld", sol);
}
int main()
{
    read();
    solve();
    write();
    return 0;
}