您的位置:首页 > 其它

uva 11538 组合数学

2014-06-12 01:19 417 查看
直接推公式

AC代码如下:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

unsigned long long ans, n, m;

int main(){
while( cin >> n >> m && !( n == 0 && m == 0 ) ){
if( n > m ){
swap( n, m );
}
ans = m * n * ( m + n - 2 ) + 2 * n * ( n - 1 ) * ( 3 * m - n - 1 ) / 3;
cout << ans << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: