uva 11538 Chess Queen<计数>
链接: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<计数>的更多相关文章
- Uva 11538 - Chess Queen
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- 组合数学 UVa 11538 Chess Queen
Problem A Chess Queen Input: Standard Input Output: Standard Output You probably know how the game o ...
- 【基本计数方法---加法原理和乘法原理】UVa 11538 - Chess Queen
题目链接 题意:给出m行n列的棋盘,当两皇后在同行同列或同对角线上时可以互相攻击,问共有多少种攻击方式. 分析:首先可以利用加法原理分情况讨论:①两皇后在同一行:②两皇后在同一列:③两皇后在同一对角线 ...
- 【组合计数】UVA - 11538 - Chess Queen
考虑把皇后放在同一横排或者统一纵列,答案为nm(m-1)和nm(n-1),显然. 考虑同一对角线的情况不妨设,n<=m,对角线从左到右依次为1,2,3,...,n-1,n,n,n,...,n(m ...
- UVa 11538 Chess Queen (排列组合计数)
题意:给定一个n*m的棋盘,那么问你放两个皇后相互攻击的方式有多少种. 析:皇后攻击,肯定是行,列和对角线,那么我们可以分别来求,行和列其实都差不多,n*A(m, 2) + m*A(n, 2), 这是 ...
- UVa11538 A Chess Queen
A Chess Queen Problem A Chess Queen Input: Standard Input Output: Standard Output You probably know ...
- 【计数原理】【UVA11538】 Chess Queen
传送门 Description 给你一个n*m的棋盘,在棋盘上放置一黑一白两个皇后,求两个皇后能够互相攻击的方案个数 Input 多组数据,每组数据包括: 一行,为n和m 输入结束标志为n=m=0. ...
- 【策略】UVa 278 - Chess
Chess Almost everyone knows the problem of putting eight queens on an chessboard such that no Quee ...
- UVA11538 - Chess Queen(数学组合)
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
随机推荐
- maven多工程构建与打包
目标:webapp_aggregator为聚合和父pom工程,不包含代码和资源,webapp为主web工程,webapp_module1为子web工程,webapp_common为基础子工程,两个we ...
- Android开发-API指南-服务
Service 英文原文:http://developer.android.com/guide/components/services.html 采集(更新)日期:2014-12-23 原博客:htt ...
- Android开发-API指南-<application>
<application> 英文原文:http://developer.android.com/guide/topics/manifest/application-element.html ...
- 【LeetCode】11. Container With Most Water
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...
- PMP考试--成本管理中常用的概念
如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 净现值(NPV) Net Present Value 在项目计算期内,按行业基准 ...
- socket学习笔记——并发服务器与I/O程序分割客户端
client.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <u ...
- 关于java.lang.IllegalStateException
今天调试程序时遇到了java.lang.IllegalStateException org.apache.catalina.connector.ResponseFacade.sendRedirect( ...
- AX 的 NumberSequences
EG: 在库存模块新加一个numberSequences. 1. 新加一个EDT\ SML_Test1; 2. 在库存模块的 class\NumberSeqReference_Inventory\Lo ...
- Does FTK index search support regular expression?
Some of my friends ask me a question: "Does FTK index search support regular expression?" ...
- leetcode 83
83. Remove Duplicates from Sorted List Given a sorted linked list, delete all duplicates such that e ...