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;
    }
  • 相关阅读:
    day60----日考
    css之单位
    如何装双系统win10下装Ubuntu
    css之Grid Layout详解
    css之position详解
    html+css的用户注册界面
    self-introduction
    ps常用操作
    前端基础之BOM和DOM
    emment语法
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5802519.html
Copyright © 2011-2022 走看看