zoukankan      html  css  js  c++  java
  • HDU 5621 KK's Point

    N个点中任意选取四个点,就能产生一个圆内的交点,所以圆内总共有C(N,4)个交点,圆上有N个,相加就可以了。

    注意:组合数运算的时候会爆longlong,中间先除一下就可以了。

    #include <stdio.h>
    #include <algorithm>
    #include <string.h>
    #include <queue>
    #include <stack>
    #include <map>
    #include <vector>
    using namespace std;
    
     long long n;
    
    int main()
    {
        int T;
        scanf("%d", &T);
        while (T--)
        {
            scanf("%lld", &n);
            long long ans1 = n*(n - 1);
            long long ans2 = (n - 2)*(n - 3);
    
            ans1 = ans1 / 2;
            ans2 = ans2 / 2;
    
            if (ans1 % 3 == 0) ans1 = ans1 / 3;
            else ans2 = ans2 / 3;
    
            if (ans1 % 2 == 0) ans1 = ans1 / 2;
            else ans2 = ans2 / 2;
    
            printf("%lld
    ", ans1*ans2 + n);
        
        }
        return 0;
    }
  • 相关阅读:
    case when if
    存储过程 、函数和事务
    poj 2263
    hdu -1874
    poj 2472
    2544 hdu
    模板floyed
    模板Dijkstra
    hdu 2066
    hdu 2544
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5189052.html
Copyright © 2011-2022 走看看