zoukankan      html  css  js  c++  java
  • CodeForces 701A Cards

    每一组的和为$frac{{2×sumlimits_{i = 1}^n {a[i]} }}{n}$,然后暴力配对就可以了。

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-8;
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    template <class T>
    inline void read(T &x)
    {
        char c = getchar(); x = 0;while(!isdigit(c)) c = getchar();
        while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar();  }
    }
    
    const int maxn=110;
    int a[maxn],sum,n,f[maxn];
    
    int main()
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
        sum=sum/(n/2);
        for(int i=1;i<=n;i++)
        {
            if(f[i]==1) continue; f[i]=1;
            for(int j=1;j<=n;j++)
            {
                if(f[j]==1) continue;
                if(a[i]+a[j]==sum)
                {
                    printf("%d %d
    ",i,j); f[j]=1;
                    break;
                }
            }
        }
        return 0;
    }
  • 相关阅读:
    sql 索引创建
    sql 触发器
    sql 中延迟执行
    sql 存储过程 分页
    BETWEEN and
    sql case when 速记
    Set无序怎么办?
    TCP为什么需要3次握手与4次挥手
    定时器
    JAVA 类加载器 第14节
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5802519.html
Copyright © 2011-2022 走看看