How Many Points of Intersection?
来源:互联网 发布:知乎双刀周杰伦 编辑:程序博客网 时间:2024/06/11 21:14
We have two rows. There are a dots on the top row 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. 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 ofP(a, b). Look at the 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
数学题,找规律
#include<iostream>#include<stdio.h>#include<math.h>#include<string.h>#include<stdlib.h>#include<algorithm>using namespace std;int main(){ int a,b,i,j,t=0; long long int sum,s; while(scanf("%d%d",&a,&b)!=EOF) { t++; sum=0;s=0; if(a==0&&b==0) break; for(i=1;i<a;i++) s=s+i; for(j=1;j<b;j++) sum=sum+j; sum=sum*s; printf("Case %d: %lld\n",t,sum); }}
- How Many Points of Intersection?
- How Many Points of Intersection?
- How Many Points of Intersection?
- How Many Points of Intersection?
- UVa 10790 How Many Points of Intersection?
- uva 10790 How Many Points of Intersection?
- uva 10790 - How Many Points of Intersection?
- uva-10790-How Many Points of Intersection?
- UVa 10790 - How Many Points of Intersection?
- 10790 - How Many Points of Intersection?
- Uva 10790 - How Many Points of Intersection?
- 10790 - How Many Points of Intersection?
- UVa 10790 - How Many Points of Intersection?
- 10790 - How Many Points of Intersection?
- UVA 10790 How Many Points of Intersection?
- UVA10790- How Many Points of Intersection?
- uva 10790 - How Many Points of Intersection
- uva 10790 How Many Points of Intersection?
- cocos2d-x 3.0 final 移植 android
- Android实战技巧:ViewStub的应用
- QWT
- linux 计划任务定时发邮件 phpmailer 和 thinkphp
- Android模糊示例-RenderScript-附效果图与代码
- How Many Points of Intersection?
- ios的手势操作之UIGestureRecognizer浅析
- CCS Cannot open soure file "***"
- 模拟——Parencodings
- codeforces 15C Industrial Nim(NIM 博弈)
- 陽卦多陰章
- Android之网络下载与图片解码-----网络图片浏览器
- linux 内核分析之list_head
- 关于YUV420转RGB24