首页 > 其他 > 详细

How Many Points of Intersection?

时间:2014-07-16 18:46:22      阅读:382      评论:0      收藏:0      [点我收藏+]

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

题意:两条水平线,分别有n,m个点,点之间两两连线,求有多少个交点。

题解:手动模拟一下,然后用不完全归纳法,就可以得到公式ans=(n-1)*n/2*(m-1)*m/2;

bubuko.com,布布扣
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<cstring>
 5 using namespace std;
 6 long long m, n;
 7 int main(){
 8     int tt=1;
 9      while(~scanf("%lld%lld",&n,&m)){
10         if(n==0&&m==0)break;
11        printf("Case %d: %lld\n",tt++,(n-1)*n/2*(m-1)*(m)/2);
12      }
13 }
View Code

 

How Many Points of Intersection?,布布扣,bubuko.com

How Many Points of Intersection?

原文:http://www.cnblogs.com/chujian123/p/3845130.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!