Cod sursa(job #575510)

Utilizator desoComan Andrei deso Data 8 aprilie 2011 13:41:16
Problema Dreptunghiuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.04 kb
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define pb push_back
#define sz size()
#define SORT(x) sort(x.begin(), x.end())
#define REVERSE(x) reverse(x.begin(), x.end())
#define REP(x, hi) for (int x=0; x<(hi); x++)
#define FOR(x, lo, hi) for (int x=(lo); x<(hi); x++)
#define FORALL(it,x) for (typeof(x.begin()) it=x.begin(); it!=x.end(); it++)
#define INFILE "dreptunghiuri.in" 
#define OUTFILE "dreptunghiuri.out"

ifstream fin (INFILE);
ofstream fout (OUTFILE);

int n, m;

int main()
{
  fin >> n >> m;
  long long ans = 0;
  n--;
  m--;
  FOR(i, 1, n+1)
  FOR(j, 1, m+1)
    if( i!=j )
      ans += (n+1-i)*(m+1-j);
    else 
    {
      ans += (n+1-i)*(m+1-j) + i-1;
    }

  fout << ans << endl;
	
	return 0;
}