zoukankan      html  css  js  c++  java
  • 2018年东北农业大学春季校赛 E wyh的集合 【数学】

    题目链接

    https://www.nowcoder.com/acm/contest/93/F

    思路
    其实容易知道在两个不同集合里
    假设元素个数 分别为 a b

    然后对于第一个集合里的每一个元素 都可以连 b 条边

    所以最大边数 就是 a * b
    现在要做的 就是 将 n 分成两个数 使得这两个数 成绩最大

    偶数 就是 n/2 * n/2
    奇数 就是 (n/2 + 1) * n/2

    AC代码

    #include <cstdio>
    #include <cstring>
    #include <ctype.h>
    #include <cstdlib>
    #include <cmath>
    #include <climits>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <deque>
    #include <vector>
    #include <queue>
    #include <string>
    #include <map>
    #include <stack>
    #include <set>
    #include <numeric>
    #include <sstream>
    #include <iomanip>
    #include <limits>
    
    #define CLR(a) memset(a, 0, sizeof(a))
    #define pb push_back
    
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef pair <int, int> pii;
    typedef pair <ll, ll> pll;
    typedef pair<string, int> psi;
    typedef pair<string, string> pss;
    
    const double PI = 3.14159265358979323846264338327;
    const double E = exp(1);
    const double eps = 1e-30;
    
    const int INF = 0x3f3f3f3f;
    const int maxn = 1e4 + 5;
    const int MOD = 1e9 + 7;
    
    int main()
    {
        int T;
        scanf("%d", &T);
        while (T--)
        {
            ll n;
            scanf("%lld", &n);
            if (n & 1)
                printf("%lld
    ", n / 2 * (n / 2 + 1));
            else
                printf("%lld
    ", (n / 2) * (n / 2));
        }
    }
    
  • 相关阅读:
    表单小知识
    HTML列表,表格与媒体元素
    P1008 三连击
    打鱼晒网问题
    最小编辑距离算法
    算法设计与分析--01背包问题(动态规划法解决)
    文件读写函数
    C语言中数据输入输出到文件操作freopen()函数(1)
    输入输出框架(未完待续)
    阶乘1到阶乘n的和
  • 原文地址:https://www.cnblogs.com/Dup4/p/9433150.html
Copyright © 2011-2022 走看看