How Many Points of Intersection? 

We have two rows. There are a dots on the toprow andb 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 computeP(a, b), the number of intersections in between the two rows. For example, in the following figurea = 2 and b = 3. This figure illustrates thatP(2, 3) = 3.

Input

Each line in the input will contain two positive integers a(0 <a20000) andb (0 < b20000).Input is terminated by a line where botha and b are zero. Thiscase should not be processed. You will need to process at most 1200 sets of inputs.

Output

For each line of input, printin a line the serial of output followed by the value ofP(a, b). Look atthe output for sample input for details. You can assume that the output for the test cases will fit in64-bit signed integers.

Sample Input

2 2
2 3
3 3
0 0

Sample Output

Case 1: 1
Case 2: 3
Case 3: 9

解题思路请参考: http://www.cnblogs.com/xiaocai905767378/archive/2011/04/27/2030213.html

注意啊注意: 用long long

row_a = 20000

roe_b = 20000 时, 会超啊~

AC代码:

#include<stdio.h>

long long a, b;
int cas = 0; int main() {
while(scanf("%lld %lld", &a, &b) != EOF) {
if(a == 0 && b == 0)
break;
long long ans = (a * (a-1) * b * (b-1) / 4);
printf("Case %d: %lld\n", ++cas, ans);
}
return 0;
}

UVA 10790 (13.08.06)的更多相关文章

  1. UVA 253 (13.08.06)

     Cube painting  We have a machine for painting cubes. It is supplied withthree different colors: blu ...

  2. UVA 573 (13.08.06)

     The Snail  A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...

  3. UVA 10499 (13.08.06)

    Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...

  4. UVA 10025 (13.08.06)

     The ? 1 ? 2 ? ... ? n = k problem  Theproblem Given the following formula, one can set operators '+ ...

  5. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  6. UVA 465 (13.08.02)

     Overflow  Write a program that reads an expression consisting of twonon-negative integer and an ope ...

  7. UVA 10494 (13.08.02)

    点此连接到UVA10494 思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~ AC代码: #include<stdio.h> #include<string.h> ...

  8. UVA 424 (13.08.02)

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. Heextended his ...

  9. UVA 10106 (13.08.02)

     Product  The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...

随机推荐

  1. 4. CMake 系列 - 项目添加编译选项

    目录 1. 项目目录结构 2. 相关代码 2.1 add 模块 2.2 sub 模块 2.3 example 模块 2.4 顶层 CMakeLists.txt 3. 配置&编译 1. 项目目录 ...

  2. 实现手机端上下左右滑屏的jq原生代码和使用库·两种办法

    先来一个原生的.我使用的是jq. 需要注意的地方就是被触发的元素最好不要是body,这个代码也可以修改,如果obj传进来的是body那么,$(this)必须是你的监听元素,不然会冒泡泡,整个项目就…… ...

  3. bzoj 1100

    思路:好脑洞啊... 把边和角转化为字符串,然后用反串跑kmp... #include<bits/stdc++.h> #define LL long long #define fi fir ...

  4. Python加密模块-pycryptodome

    这个模块可以避开Pycrypto安装时带来的一系列包依赖问题. 安装命令: pip install pycryptodome 使用实例: from Crypto.Cipher import AES k ...

  5. 【BZOJ 3998】 3998: [TJOI2015]弦论 (SAM )

    3998: [TJOI2015]弦论 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 2627  Solved: 881 Description 对于一 ...

  6. [BZOJ2431][HAOI2009]逆序对数列(DP)

    从小到大加数,根据加入的位置转移,裸的背包DP. #include<cstdio> #include<cstring> #include<algorithm> #d ...

  7. [转]Android Studio开发入门-引用jar及so文件

    注意: 1.jar包在app的libs目录 2.so文件放在src/main”目录中名为“jniLibs”的目录 一.引用jar文件    1.将jar文件复制.粘贴到app的libs目录中:    ...

  8. linux基础命令学习 (九)文本操作

    一.head 1.语法: head [选项] [文件] 2.选项 -q 隐藏文件名 -v 显示文件名 -c<字节> 显示字节数 -n<行数> 显示的行数 3.示例 范例一:查看 ...

  9. 【转】如何修改maven工程jdk版本

    1.使用maven的时候,默认会使用1.5版本的JDK,并且也是编译成1.5的,我的电脑里面用的JDK是1.7的,1.8也出来了,没理由还用1.5的吧!所以我手动改成了1.7,郁闷的是,每次 mave ...

  10. Java容器-引入Guava类库

    目录 1.只读设置 2.函数式编程+组合式编程 3.约束条件 4.集合操作(并集.差集.交集) 代码实现 1.只读设置 public static void main(String [] args){ ...