组合数
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 100010
using namespace std;
int n,m;
int main()
{
#ifndef ONLINE_JUDGE
freopen("ce.in","r",stdin);
#endif
while(scanf("%d%d",&n,&m)==2)
{
if(n==0&&m==0) break;
long long cur_ans=0;
if(n>m) swap(n,m);
for(int i=1;i<=n-1;i++) cur_ans+=1ll*i*(i-1);
// printf("cur_ans=%lld\n",cur_ans);
printf("%lld\n",1ll*(cur_ans)*4+1ll*n*m*(n+m-2)+1ll*2*(m-n+1)*n*(n-1));
}
return 0;
}
原文:https://www.cnblogs.com/fengxunling/p/10697977.html