链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2533

三个方向, 横,竖,对角线~

 #include<iostream>
#include<cstdio>
using namespace std; int main()
{
long long int n,m;
while(scanf("%lld%lld",&n,&m)!=EOF&&n&&m)
{
if(n>m)
swap(n,m);
long long int ans=(n-)*n*m + (m-)*m*n + *n*(n-)*(m-n+);
ans+=**(n-)*(n-)*(n)/;
printf("%lld\n",ans);
}
return ;
}

uva 11538 Chess Queen<计数>的更多相关文章

  1. Uva 11538 - Chess Queen

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  2. 组合数学 UVa 11538 Chess Queen

    Problem A Chess Queen Input: Standard Input Output: Standard Output You probably know how the game o ...

  3. 【基本计数方法---加法原理和乘法原理】UVa 11538 - Chess Queen

    题目链接 题意:给出m行n列的棋盘,当两皇后在同行同列或同对角线上时可以互相攻击,问共有多少种攻击方式. 分析:首先可以利用加法原理分情况讨论:①两皇后在同一行:②两皇后在同一列:③两皇后在同一对角线 ...

  4. 【组合计数】UVA - 11538 - Chess Queen

    考虑把皇后放在同一横排或者统一纵列,答案为nm(m-1)和nm(n-1),显然. 考虑同一对角线的情况不妨设,n<=m,对角线从左到右依次为1,2,3,...,n-1,n,n,n,...,n(m ...

  5. UVa 11538 Chess Queen (排列组合计数)

    题意:给定一个n*m的棋盘,那么问你放两个皇后相互攻击的方式有多少种. 析:皇后攻击,肯定是行,列和对角线,那么我们可以分别来求,行和列其实都差不多,n*A(m, 2) + m*A(n, 2), 这是 ...

  6. UVa11538 A Chess Queen

    A Chess Queen Problem A Chess Queen  Input: Standard Input Output: Standard Output You probably know ...

  7. 【计数原理】【UVA11538】 Chess Queen

    传送门 Description 给你一个n*m的棋盘,在棋盘上放置一黑一白两个皇后,求两个皇后能够互相攻击的方案个数 Input 多组数据,每组数据包括: 一行,为n和m 输入结束标志为n=m=0. ...

  8. 【策略】UVa 278 - Chess

    Chess  Almost everyone knows the problem of putting eight queens on an  chessboard such that no Quee ...

  9. UVA11538 - Chess Queen(数学组合)

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

随机推荐

  1. Comparing cards

    For built-in types, there are conditional operators (<, >, ==, etc.) that compare values and d ...

  2. 解决在 MVC  局部视图中加载 ueditor 编辑器时, 编辑器加载不出的 bug

    在 MVC 局部视图中,有时我们需要 加载 ueditor 编辑器,或进行局部刷新, 但是在加载局部视图后,ueditor 编辑器加载不出,这是由于 ueditor 使用的缓存,只要清空缓存,重新实例 ...

  3. Could not find action or result

    [WARN ] 2013-11-21 14:08:16 :Could not find action or resultThere is no Action mapped for namespace ...

  4. 学习资料 数据查询语言DQL

    数据查询语言DQL介绍及其应用: 查询是SQL语言的核心,SQL语言只提供唯一一个用于数据库查询的语句,即SELECT语句.用于表达SQL查询的SELECT语句是功能最强也是最复杂的SQL语句,它提供 ...

  5. 洛谷P2728 纺车的轮子 Spinning Wheels

     P2728 纺车的轮子 Spinning Wheels 29通过 66提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交  讨论  题解 最新讨论 暂时没有讨论 题目背景 一架纺车 ...

  6. JavaBean和内省

    JavaBean和内省 JavaBean是一个遵循特定的写法的java类     1. 必须有一个无参的构造方法     2.属性私有化     3.私有你给的属性必须通过public类型的方法暴露给 ...

  7. malloc、calloc、realloc的区别

    (1)C语言跟内存分配方式 <1>从静态存储区域分配.       内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在.例如全局变量.static变量.<2> ...

  8. Leetcode028. Implement strStr()

    class Solution { public: int strStr(string haystack, string needle) { ; //needle empty ; //haystack ...

  9. Use EnCase to acquire data from a smartphone

    Yesterday someone asked me a question can EnCase acquire data from a smartphone, and my reply was &q ...

  10. 使chrome支持跨域访问

    在做后台开发的时候,使用了iframe框架.后台主页面如下: <div style="width:185px; overflow: hidden;" id="wes ...