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 ...
 
随机推荐
- 给 K8s API “做减法”:阿里巴巴云原生应用管理的挑战和实践
			
作者 | 孙健波(天元) 阿里巴巴技术专家本文整理自 11 月 21 日社群分享,每月 2 场高质量分享,点击加入社群. 早在 2011 年,阿里巴巴内部便开始了应用容器化,当时最开始是基于 LXC ...
 - 【mysql】Mysql5.7--sys_schema视图
			
前言: MySQL 5.7中引入了一个新的sys schema,sys是一个MySQL自带的系统库,在安装MySQL 5.7以后的版本,使用mysqld进行初始化时,会自动创建sys库. sys库里面 ...
 - WPF TextBox绑定Int类型的属性
			
TextBox双向绑定int属性,清空输入框时Setter方法未触发. 我的解决方案: 1.属性置为int?: 2.xmlns:sys="clr-namespace:System;assem ...
 - TreeViewItem节点添加图标后再加header
			
1.需要实现的效果如图 2.解决方案 1).给TreeViewItem中添加children,children为包含一个stackpanel,在stackpanel中包含Image和TextBlock ...
 - Python 爬取猫眼电影《无名之辈》并对其进行数据分析
			
前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 罗昭成 PS:如有需要Python学习资料的小伙伴可以加点击下方链接 ...
 - 合格的施工图是如何绘制的?必须要get这四点,大多数人都不知道
			
对于工程设计师来说加班通宵赶图改图是常有的事情,如何绘制一套合格的施工图?这是很多工程设计师都会问的问题. 绘制一套合格的施工图,你需要注意以下四点: 一.明确施工图的作用和目的 1. 工程设计的细化 ...
 - H5 移动端 键盘遮挡焦点元素解决方案
			
前言 最近在做 webapp,遇到了很多移动端兼容的问题,其中一个问题就是:输入框触发 focus 后,键盘弹出,然后遮住了输入框. 然后在Android和IOS上,这个问题的表现形式不一样,而原生键 ...
 - Fiddler使用技巧:强大的数据文本编解码功能
			
- 总览 打开Fiddler后,使用快捷键Ctrl+e或者点击菜单Tools-->TextWizard...即可进入TextWizard界面. 界面上方为输入框,用来输入需要编码或解码的数据. ...
 - iOS开发证书那点事儿
			
iOS开发是用Xcode作为开发工具,Xcode在安装之后就自带了模拟器(Simulator).模拟器是个好工具,它对用户没有任何要求,但是我们必须牢记一件事:开发出来的App最终是要在真机上执行,没 ...
 - Ajax错误
			
如果ajax访问不到后台对应的controller的方法,直接报错,首先查看url访问路径,如果路径没错误,再利用谷歌开发者工具来运行一下,是否存在基本语法错误,比如字符写错了,多一个少一个逗号, 如 ...