Uva 11538 Chess Queen (数学规律题)
2013-05-14 13:58
381 查看
Problem A
Chess Queen
Input: Standard Input
Output: Standard Output
You probably know how the game of chess is played and how chess queen operates. Two chess queens are in attacking position when they are on same row, column or diagonal of a chess board. Suppose two such chess queens (one black and the other white) are placed on (2x2) chess board. They can be in attacking positions in 12 ways, these are shown in the picture below:
View Code
Chess Queen
Input: Standard Input
Output: Standard Output
You probably know how the game of chess is played and how chess queen operates. Two chess queens are in attacking position when they are on same row, column or diagonal of a chess board. Suppose two such chess queens (one black and the other white) are placed on (2x2) chess board. They can be in attacking positions in 12 ways, these are shown in the picture below:
//11538 Chess Queen Accepted C++ 0.024 2013-04-22 08:15:00 #include <iostream> #include <algorithm> #include <cstdio> using namespace std; int main() { unsigned long long n, m; while(cin >> n >> m) { if(!m&&!n) break; if(n>m) swap(n, m); long long res = n*m*(m+n-2)+2*n*(n-1)*(3*m-n-1)/3 ; cout << res << endl; } return 0; }
View Code
相关文章推荐
- Uva - 11538 - Chess Queen(数学推导)
- UVA 11538 Chess Queen(数学)
- UVA-11538 Chess Queen(数学)
- UVa 11538 - Chess Queen (组合数学)
- UVA 11538 Chess Queen (数学)
- UVa 11538 Chess Queen
- UVA 12683 Odd and Even Zeroes(数学—找规律)
- UVA 11538 - Chess Queen(数论+计数问题)
- UVa 10162 Last Digit (数学规律)
- 找规律,数学(巨大的斐波那契数列,uva 11582)
- UVA 11538【象棋中的皇后】Chess Queen-----2015年1月24日
- UVa 11538 - Chess Queen
- uva 846 Steps(数学规律)
- Beehive UVALive - 7528 (找规律+数学思维)
- uva 11538 - Chess Queen 先分步还是先分类? 计数问题
- 代码地方UVa 11538 - Chess Queen
- UVA11538-Chess Queen
- UVA - 11538 Chess Queen
- UVA 11538 Chess Queen