Cod sursa(job #350605)

Utilizator andrei-alphaAndrei-Bogdan Antonescu andrei-alpha Data 24 septembrie 2009 23:25:41
Problema Dreptunghiuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.54 kb
using namespace std;

#include <set>
#include <map>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <utility>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define pb push_back
#define size(V) ((int)(V.size()))
#define f first
#define s second
#define II inline
#define ll long long
#define db double
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define all(v) v.begin() , v.end()
#define CC(v) memset((v),0,sizeof((v)))
#define CP(v,w) memcpy((v),(w),sizeof((w)))
#define mp make_pair
#define mod 654321
#define oo 1<<30

#define IN  "dreptunghiuri.in"
#define OUT "dreptunghiuri.out"

typedef vector<int> VI;
typedef pair<int,int> pi;
typedef vector<string> VS;
template<class T> string toString(T n) {ostringstream ost;ost<<n;ost.flush();return ost.str();}
typedef vector<string> VS;

int N,M;
bool viz[1<<20];

II void scan()
{
	freopen(IN,"r",stdin);
	freopen(OUT,"w",stdout);
	scanf("%d%d",&N,&M);
}

II int compute(int x,int y)
{
	int count = (N - x + 1) * (M - y + 1);
	int rez = (x - 2) * (y - 2) * count;
	
//	printf("pt %d cu %d %d nr=%d\n",x,y,rez / count,count);
	
	return rez;
}

II void solve()
{
	int rez = 0;
	
	rez += N * (N - 1) * M * (M - 1) >> 2;
	
	FOR(x,3,min(N,M) )
		rez += compute(x,x);
	
	printf("%d\n",rez);
}

int main()
{
	scan();
	solve();
	return 0;
}