UVA 10790 How Many Points of Intersection? 组合数学
We have two rows. There are a dots on the top row and b dots on the bottom row. We draw line segments
connecting every dot on the top row with every dot on the bottom row. The dots are arranged in such
a way that the number of internal intersections among the line segments is maximized. To achieve this
goal we must not allow more than two line segments to intersect in a point. The intersection points on
the top row and the bottom are not included in our count; we can allow more than two line segments
to intersect on those two rows. Given the value of a and b, your task is to compute P(a; b), the number
of intersections in between the two rows. For example, in the following gure a = 2 and b = 3. This
gure illustrates that P(2; 3) = 3.

Input
Each line in the input will contain two positive integers a (0 < a 20000) and b (0 < b 20000).
Input is terminated by a line where both a and b are zero. This case should not be processed. You will
need to process at most 1200 sets of inputs.
Output
For each line of input, print in a line the serial of output followed by the value of P(a; b). Look at the
output for sample input for details. You can assume that the output for the test cases will t in 64-bit
signed integers.
Sample Input
2 2
2 3
3 3
0 0
Sample Output
Case 1: 1
Case 2: 3
Case 3: 9
题意:输入a,b表示上面一条直线有a个点,下面一条直线有b个点,连接上下直线的所有点,问这些线段的交点有几个?题目保证每一个交点只会有两条线段相交于此。
分析:
上面一条直线任取两点和下面一条直线任取两点就会形成一个交点。
所以ans=C(a,2)*C(b,2)。
解毕。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
//freopen("input.txt","r",stdin);
ll a,b;
int kase=;
while(~scanf("%lld%lld",&a,&b)&&a&&b)
{
printf("Case %d: %lld\n",kase++,a*(a-)*b*(b-)/);
}
return ;
}
UVA 10790 How Many Points of Intersection? 组合数学的更多相关文章
- UVA 10790 How Many Points of Intersection?
How Many Points of Intersection? We have two rows. There are a dots on the top row and b dots on ...
- UVA 10790 (13.08.06)
How Many Points of Intersection? We have two rows. There are a dots on the toprow andb dots on the ...
- How Many Points of Intersection?
uva10790:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_prob ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- Volume 1. Maths - Misc
113 - Power of Cryptography import java.math.BigInteger; import java.util.Scanner; public class Main ...
- Coursera Robotics系列课心得
Robotics Perception Professor Kostas and Jianbo Shi week 1: camera model 凸透镜成像原理:凸透镜焦点与焦距是固定的,这是物理性质 ...
- [算法]A General Polygon Clipping Library
A General Polygon Clipping Library Version 2.32 http://www.cs.man.ac.uk/~toby/alan/software/gpc.h ...
- [非官方]ArcGIS10.2 for Desktop扩展工具包——XTools Pro
XTools Pro 是一套为ArcGIS平台设计的矢量空间分析. 形状转换和表管理扩展工具,大大增强了 ArcGIS 的功能,使用该工具能够提高 ArcGIS 用户的效率和性能. XTools Pr ...
- Circles and Pi
Circles and Pi Introduction id: intro-1 For as long as human beings exist, we have looked to the sky ...
随机推荐
- 【转】ASP.NET Core 如何设置发布环境
在ASP.NET Core中自带了一些内置对象,可以读取到当前程序处于什么样的环境当中,比如在ASP.NET Core的Startup类的Configure方法中,我们就会看到这么一段代码: publ ...
- 安装Goland开发工具
安装Goland开发工具 开发工具: 文本类的编辑器:记事本,notepad,sublime text,atom... 通过命令执行程序 IED:集成开发环境(integrated develop ...
- HTTP 状态码及含义
来自 Koa.js 官方文档中关于设置请求响应的部分 response.status=,列出了从 1xx ~ 5xx HTTP 状态码及含义,现摘录如下: 100 "continue&quo ...
- 《Head First C#》外星人入侵WPF编写源码
目录 引言 前期工作 只要努力没有什么困难可以难倒你,加油骚年! @(外星人入侵(WPF编写)) 引言 自学的C#,看了几本教材讲的都是程序代码,网上找的也有视屏,但都比较老了.只会打些代码为不晓得为 ...
- CSS3 2D变形 transform---移动 translate(x, y), 缩放 scale(x, y), 旋转 rotate(deg), transform-origin, 倾斜 skew(deg, deg)
transform是CSS3中具有颠覆性的特征之一,可以实现元素的位移.旋转.倾斜.缩放,甚至支持矩阵方式,配合过渡和即将学习的动画知识,可以取代大量之前只能靠Flash才可以实现的效果. 变形转换 ...
- awk 输出前 N 列的最简单方法
最近遇到一种场景,需要输出一个文本信息的前 N 列. 众所周知 cut 可以指定分隔符并指定列的范围,如 cut -d' ' -f-4 就是以空格为分隔符输出前 4 列.但是 cut 的分隔符只能是一 ...
- export default和export的使用
export default和export都是用来向外暴露成员 export default 向外暴露的成员可以使用任意的变量来接收,在一个模块中,export default只允许向外暴露一次,可以 ...
- 1-函数返回值-return详解及应用-1
return 返回值 可以是:数字.字符串.布尔.函数.对象(元素\[]\{}\null).未定义 <script> function fn1(){return 100;} aler ...
- Python—函数进阶篇
lambda表达式(匿名函数表达式) 作用:创建一个匿名函数对象.同def类似,但不提供函数名. 语法:lambda [形参1,形参2,...] : 表达式 语法说明 lambda 只是一个表达式,它 ...
- Python—基础之杂货铺
列表.元组.字典之前的互相转换 列表与元组的转换 # 列表转换成元组:使用 tuple 函数 num_list = [3, 6, 9] num_tuple = tuple(num_list) prin ...