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? 组合数学的更多相关文章

  1. 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 ...

  2. 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 ...

  3. How Many Points of Intersection?

    uva10790:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_prob ...

  4. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  5. Volume 1. Maths - Misc

    113 - Power of Cryptography import java.math.BigInteger; import java.util.Scanner; public class Main ...

  6. Coursera Robotics系列课心得

    Robotics Perception Professor Kostas and Jianbo Shi week 1: camera model 凸透镜成像原理:凸透镜焦点与焦距是固定的,这是物理性质 ...

  7. [算法]A General Polygon Clipping Library

    A General Polygon Clipping Library Version 2.32    http://www.cs.man.ac.uk/~toby/alan/software/gpc.h ...

  8. [非官方]ArcGIS10.2 for Desktop扩展工具包——XTools Pro

    XTools Pro 是一套为ArcGIS平台设计的矢量空间分析. 形状转换和表管理扩展工具,大大增强了 ArcGIS 的功能,使用该工具能够提高 ArcGIS 用户的效率和性能. XTools Pr ...

  9. Circles and Pi

    Circles and Pi Introduction id: intro-1 For as long as human beings exist, we have looked to the sky ...

随机推荐

  1. java 连缀用法

    连缀用法,即是在实例化对象时,同时为对象的属性设值. 如示例所示,在创建对象时,同时调用属性的设值函数,为属性赋值 Apple apple = new Apple() .setColor(" ...

  2. Apache ActiveMQ序列化漏洞(CVE-2015-5254)复现

    Apache ActiveMQ序列化漏洞(CVE-2015-5254)复现 一.漏洞描述 该漏洞源于程序没有限制可在代理中序列化的类.远程攻击者可借助特制的序列化的java消息服务(JMS)Objec ...

  3. node.js如何批量赋值

    1. 数组解析赋值 let a = 1; let b = 2; let c = 3; 等同于 let [a, b, c] = [1, 2, 3]; 默认值 let [a, b = "B&qu ...

  4. 【随笔】CLR:向头对象(Object Header)迈进一大步!!!

    前言 在我之前一篇随笔里(戳我),我们知道,一个引用类型的对象,包含了2个额外的开销,一个是头对象(object header),一个是MT.我们接下来看看头对象到底有多神秘... Object He ...

  5. 服务端性能测试技能tree

    ALL: Left: Right: 摘抄一下(觉得不错) 以下来自百度百科 ---- 软件性能测试 软件性能测试是在交替进行负荷和强迫测试时常用的术语.理想的“软件性能测试”(和其他类型的测试)应在需 ...

  6. C#中巧用Lambda表达式实现对象list进行截取

    场景 有一个对象的list,每个对象有唯一的属性Id,并且是从1递增,现在要根据此Id属性进行截取. 其中DataTreeNode 实现 Global.Instance.PrepareCompareD ...

  7. django9-ajax

    1.ajax 局部刷新 ,不可能每次提交请求刷新整个页面 2.ajax实例 在不刷新整个的情况下完成计算器 ,ajax的post需要添加csrftoken 1)设置一个组件ajaxcsrf.html ...

  8. .net core 使用ViewComponent

    .net core 中的局部视图组件是ViewComponent,可以用于建制重复使用公共功能组件 一.新建一个类DemoViewComponent(必须以ViewComponent结尾)且继承Vie ...

  9. JavaScript:for循环中let与var变量的绑定

    碰到一道题: for(var i=0;i<2;i++){ setTimeout(function(){ console.log(i); },100) } //输出结果为:2 2 for(let ...

  10. NSURLSession的知识小记

    1.NSURLSession的使用流程 使用NSRULSession对象创建Task, 然后执行Task 2.获取NSURLSession ()获得共享的Session + (NSURLSession ...