UVa 11538 - Chess Queen
2014-02-23 16:04
441 查看
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:
#include<iostream> #include<string.h> #include<stdio.h> using namespace std; int main() { long long int n,m,n1,sum; //freopen("aa.txt","r",stdin); while(scanf("%lld%lld",&n,&m)!=EOF) { sum=n1=0; if(n==0&&m==0) break; sum+=m*n*(n-1+m-1); if(n>m) swap(n,m); n1+=((n-1)*n*(2*n-1)/6-n*(n-1)/2)*4; n1+=(m-n+1)*n*(n-1)*2; sum+=n1; printf("%lld\n",sum); } return 0; }
View Code
相关文章推荐
- UVA 11538 - Chess Queen
- uva11538 Chess Queen
- 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 11538-Chess Queen
- 代码地方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 11538 Chess Queen
- UVa 11538 - Chess Queen
- UVa - 11538 - Chess Queen
- UVa 11538 Chess Queen (排列组合计数)