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 ...
随机推荐
- C++入门到理解阶段二基础篇(1)——简介与环境安装
1.C++ 简介 C++ 是一种静态类型的.编译式的.通用的.大小写敏感的.不规则的编程语言,支持过程化编程.面向对象编程和泛型编程. C++ 被认为是一种中级语言,它综合了高级语言和低级语言的特点. ...
- Linux中Swap与Memory内存简单介绍
1.背景介绍 这篇文章介绍一下Linux中swap与memory.对于memory没什么可说的就是机器的物理内存,读写速度低于cpu一个量级,但是高于磁盘不止一个量级.所以,程序和数据如果在内存的 ...
- 解决HttpServletRequest的输入流只能读取一次的问题
背景 通常对安全性有要求的接口都会对请求参数做一些签名验证,而我们一般会把验签的逻辑统一放到过滤器或拦截器里,这样就不用每个接口都去重复编写验签的逻辑. 在一个项目中会有很多的接口,而不同的接口可能接 ...
- MySQL 中的索引
索引用来加速查询.正常来说,当查询数据时,MySQL 需要从表的第一条记录开始,读取整个表的内容,进行查询. 但如果有索引,MySQL 可根据索引快速定位需要查询条目的具体位置,加快了查询速度. 原理 ...
- Flask笔记:信号机制
Flask中有内置的一些信号,也可以通过三方库blinker自定义信号,其实Flask内置的信号也是优先使用的blinker库,如果没有安装blinker才会使用自定义的信号机制.可以通过点击任意导入 ...
- HTML颜色名称大全
所有浏览器支持的颜色名称,所有现代浏览器都支持以下140种颜色名称(单击颜色名称或十六进制值,以将颜色视为背景颜色以及不同的文本颜色): 有关HTML颜色的完整概述,请访问我们的颜色教程. 颜色名称 ...
- C# Dictionary增加的方法
1.简单的函数,实现Dictionary如果有就替换,没有就增加的功能. /// <summary> /// Dictionary增加的方法 /// </ ...
- Nginx文章
https://www.cnblogs.com/qfb620/p/5508468.html https://www.cnblogs.com/jiangwangxiang/p/8481661.html ...
- [20190515]热备份模式与rman冲突.txt
[20190515]热备份模式与rman冲突.txt --//别人的系统做dg时打开热备份模式,忘记关闭,做rman备份时报错.做一个记录.--//实际上也怪自己,实施时没有讲清楚.通过例子说明: 1 ...
- CPU 架构SMP/NUMA,调优
CPU 架构SMP/NUMA,调优 SMP:全称是"对称多处理"(Symmetrical Multi-Processing)技术 . 是指在一个计算机上汇集了一组处理器(多CPU) ...