Uva 11538-Chess queue象棋中的皇后

详细的介绍参考刘汝佳106页……

代码:

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring> 
#include<cmath>
#include<queue>
using namespace std;
#define sf scanf
#define pf printf
#define INF 1<<29
#define eps 1e-6
const double PI=acos(-1.0);
#define lint __int64
#define LL long long 
#define ULLint unsigned long long //2^64-1>1.8*10^19
#define clr(x) memset(x,0,sizeof(x))
#define Clr(x) memset(x,-1,sizeof(x))
ULLint n,m;
int main(){
	while(cin>>n>>m,n||m){
		if(n>m)swap(n,m);//保证n比m小
		ULLint ans=2*n*(n-1)*(3*m-n-1)/3;
		ans+=m*n*(n-1)+n*m*(m-1);
		cout<<ans<<endl;
	}
	return 0;
}


你可能感兴趣的:(Uva 11538-Chess queue象棋中的皇后)