UVA 10790-How Many Points of Intersection?#

来源:互联网 发布:数据中心网络拓扑图 编辑:程序博客网 时间:2024/05/18 21:07

UVA 10790-How Many Points of Intersection?

题目大意:上面a个点,下面b个点,全部相连,问线有多少交点

解题思路:a个点取俩个 b个点取俩个,共有几种组合就是本题的解

#include <stdio.h>#include <iostream>using namespace std;long long int count(long long int x) {    x = x * (x - 1);    x = x / 2.0;    return x;}int main() {    long long int a;    long long int b;    int n = 0;    while(scanf("%lld%lld", &a, &b) && (a + b) != 0) {        long long int m;        n++;        if(a == 0 || b == 0)            m = 0;        else {            m = count(a) * count(b);        printf("Case %d: %lld\n", n, m);        }    }    return 0;}
0 0