码迷,mamicode.com
首页 > 其他好文 > 详细

How Many Points of Intersection?

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

标签:style   blog   http   color   os   art   

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?

标签:style   blog   http   color   os   art   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!