UVA 10790 (13.08.06)
来源:互联网 发布:java final存放区域 编辑:程序博客网 时间:2024/04/30 11:33
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 ofa 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 andb = 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 22 33 30 0
Sample Output
Case 1: 1Case 2: 3Case 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)
- UVA 253 (13.08.06)
- UVA 621 (13.08.06)
- UVA 10025 (13.08.06)
- UVA 591 (13.08.06)
- UVA 573 (13.08.06)
- UVA 846 (13.08.06)
- UVA 10499 (13.08.06)
- Uva 10790
- uva 10790
- UVA 10790
- uva 10790
- uva 10790
- UVA 10790
- UVA 10790
- UVA 784 (13.08.09)
- UVA 401 (13.08.01)
- UVA 10361 (13.08.01)
- HDU 4638 2013多校联合第4场 G-Group
- Assignment 9: Computational Geometry
- Android系统信息获取 之五:系统语言信息(续)-语言地区和简写对照表
- 数据业务支撑系统
- 【三句简单却值得牢记的话】
- UVA 10790 (13.08.06)
- UVA 624 - CD
- 用到的与sql相关的总结
- ASIHttpRequest详解
- UVA1099----Sharing Chocolate----在集合上的DP
- poj 1035 Spell checker ( 字符串处理 )
- apt-get 命令详解(中文),以及实例
- 转义字符及(\r,\n,\r\n)的问题
- Knight Moves