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 ...
随机推荐
- 【Linux】LVM操作添加新硬盘
目录 1.查看当前硬盘及分区情况 2.初始化/dev/sdb为PV(physical volume) 3.PV加入至VG组. 4.创建lv 5.格式化逻辑分区 6.挂载硬盘/data 7.迁移zabb ...
- 为了“小命”,这款APP一定要下!火爆了!
前言中国地震台网在 6 月 17 日测定:6 月 17 日 22 时 55 分,四川省宜宾市长宁县发生 6 级地震,震源深度 16 千米.成都高新减灾研究所通过电台广播.手机短信.电视等途径,提前 6 ...
- RabbitMQ的交换器Exchange之direct(发布与订阅 完全匹配)
1.交换器.用来接收生产者发送的消息并将这些消息路由给服务器中的队列.三种常用的交换器类型,a.direct(发布与订阅 完全匹配).b.fanout(广播).c.topic(主题,规则匹配). 2. ...
- git clone: HTTP Basic: Access denied 错误
git clone 报 HTTP Basic: Access denied 错误 解决方案: 1. 如果账号密码有变动 用这个命令 git config –-system –-unset creden ...
- LinuxShell脚本——变量和数据类型
LinuxShell脚本——变量和数据类型 摘要:本文主要学习了Shell脚本中的变量和数据类型. 变量 定义变量的语法 定义变量时,变量名和变量值之间使用“=”分隔,并且等号两边不能有空格: 变量名 ...
- 微信小程序上拉加载——分页
wxml: <view class="page"> <scroll-view class="imageViewCss_1" scroll-y= ...
- 移动OA办公——Smobiler第一个开源应用解决方案,快来get吧
产品简介 SmoONE是一款移动OA类的开源解决方案,通过Smobiler平台开发,包含了注册.登陆.用户信息等基本功能.集成了OA中使用场景较多的报销.请假.部门管理.成本中心等核心功能. 免费获取 ...
- 查询Mysql数据库所有数据库所占磁盘空间大小
查询Mysql数据库所有数据库所占磁盘空间大小: /,),' MB') as data_size, concat(truncate(sum(index_length)//,),'MB') as ind ...
- 1.JavaCC安装与测试
下面介绍的是JavaCC在windows系统中的安装与小代码测试过程. 一.JavaCC安装 步骤 :在JavaCC的官网首页下载JavaCC,然后配置电脑的环境变量,接着在dos命令行里就可 ...
- hi3559v100 sdk中双系统AMP架构的初步了解
hi3559v100是海思推出的camera soc处理器.采用的是双核处理器.一个是a7,运行的linux3.18内核.一个是a17使用的是huaweiliteos操作系统,Hi3559V100 系 ...