您的位置:首页 > 产品设计 > UI/UE

UVA 11538 Chess Queen——计数原理

2017-11-13 15:18 363 查看
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef unsigned long long ull;

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