Chess Queen UVA 11538


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>   
#include <map>
#include <string>  
#include <climits> 
#include <set>
#include <string> 
#include <sstream>
#include <utility>   
#include <ctime>
 
using std::priority_queue;
using std::vector;
using std::swap;
using std::stack;
using std::sort;
using std::max;
using std::min;
using std::pair;
using std::map;
using std::string;
using std::cin;
using std::cout;
using std::set;
using std::queue;
using std::string;
using std::istringstream;
using std::make_pair;
using std::greater;
using std::endl;

typedef long long LL;

int main()
{
	LL n, m;
	while(cin >> n >> m, n|| m)
	{
		if(n < m)
			swap(n, m);
		cout << n*n*m+n*m*m-2*n*m+2*m*(m-1)*(3*n-m-1)/3 << "\n";
	}
	return 0;
}


你可能感兴趣的:(Chess Queen UVA 11538)