直接看示例输入输出+提示

1. 统计所有数的和 sum,然后求 sum/(n/2) 的到一半数的平均值

  6

  1 5 7 4 4 3 -》1+5+7+4+4+3=24  分成3组 每组值为8

  int sumavg=sum/(n/2)=8

2. int z=sumavg-x[i]

if(x[j]==z&&!dp[i]&&!dp[j]) //如果当前数为该输出的数,且i,j没有输出过,则输出 i,j (数组下标), 且dp[i]=dp[j]=1;  

AC代码可以解释解题答案

 #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,x[],dp[];
while(scanf("%d",&n)!=EOF)
{
int sumavg=;
for(i=; i<=n; i++)
{
scanf("%d",&x[i]);
sumavg+=x[i];
}
sumavg=sumavg/(n/);
memset(dp,,sizeof(dp));
for(int i=; i<n; i++)
{
int z=sumavg-x[i];
for(int j=i+; j<=n; j++)
{
if(x[j]==z&&!dp[i]&&!dp[j])
{
dp[i]=;
dp[j]=;
printf("%d %d\n",i,j);
break;
}
}
}
}
return ;
}

CodeForces 701A Cards的更多相关文章

  1. Codeforces 701A. Cards(水)

    A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  2. codeforces 701A A. Cards(水题)

    题目链接: A. Cards 题意: 问两个数的和相同,怎么组合; AC代码: #include <iostream> #include <cstdio> #include & ...

  3. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  4. Codeforces 999F Cards and Joy(二维DP)

    题目链接:http://codeforces.com/problemset/problem/999/F 题目大意:有n个人,n*k张卡牌,每个人会发到k张卡牌,每个人都有一种喜欢的卡牌f[i],当一个 ...

  5. Codeforces 830B - Cards Sorting 树状数组

    B. Cards Sorting time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  6. codeforces #364a Cards

    cf的a题没什么好说到,100的量级,每个人给2张牌,使每个人手中的牌点数相等.保证有一种分配方案. 对每个人,先计算出手中的牌的点数,然后循环两遍拿牌就可以.   A. Cards time lim ...

  7. CodeForces 626B Cards

    瞎搞题...凭直觉+猜测写了一发,居然AC了.. #include<cstdio> #include<cstring> #include<cmath> #inclu ...

  8. Codeforces 1278F: Cards

    题目传送门:CF1278F. 题意简述: 有 \(n\) 个独立随机变量 \(x_i\),每个随机变量都有 \(p = 1/m\) 的概率取 \(1\),有 \((1-p)\) 的概率取 \(0\). ...

  9. CodeForces 830B - Cards Sorting

    将每个数字的位置存进该数字的vector中 原数组排个序从小到大处理,每次在vector里二分找到距离当前位置“最远”的位置(相差最大),更新答案 树状数组维护每个数字现在的位置和原位置之差 #inc ...

随机推荐

  1. m3u8字段意义解析

    m3u8字段意义解析 HLS,Http Live Streaming是由Apple公司定义的用于实时流传输的协议,HLS基于HTTP协议实现,传输内容包括两部分,一是M3U8描述文件,二是TS媒体文件 ...

  2. 联想Y50p预装win8系统改为win7

    &1 修改OS Optimized Defaults 开机,按[F2]进入BIOS设置,按右方向键选择到EXIT上面,按下方向键选择OS Optimized Defaults,回车,将Win8 ...

  3. ace布置小作业: 制作一个简单的电话号码归属地查询软件:JSON解析和Volly发送get请求

    大概就这个样子 用到JSON解析和Volly发送Get请求两个知识点 关于Volly的用法请看我的这篇: http://www.cnblogs.com/AceIsSunshineRain/p/5177 ...

  4. windows下git bash显示中文

    1.C:\Program Files\Git\etc\git-completion.bash: alias ls='ls --show-control-chars --color=auto' 说明:使 ...

  5. [CareerCup] 13.4 Depp Copy and Shallow Copy 深拷贝和浅拷贝

    13.4 What is the difference between deep copy and shallow copy? Explain how you would use each. 这道题问 ...

  6. Buffer lab——20145326蔡馨熠

    Buffer lab   缓冲区溢出攻击的原理 缓冲区溢出是指程序试图向缓冲区写入超出预分配固定长度数据的情况.这一漏洞可以被恶意用户利用来改变程序的流控制,甚至执行代码的任意片段.这一漏洞的出现是由 ...

  7. tabbar的自定义

    [self createCustomTabBar]; -(void)createCustomTabBar{    //创建一个UIImageView,作为底图    UIImageView *bgVi ...

  8. 20145302张薇 GDB调试汇编堆栈过程分析

    GDB堆栈跟踪与汇编调试 堆栈跟踪 源代码 使用gcc - g example.c -o example -m32指令在64位的机器上产生32位汇编,然后使用gdb example指令进入gdb调试器 ...

  9. 工作随笔——xshell4安装后应该做的一些事

    xshell4默认支持中文语言 选项→键盘和鼠标:设置快捷键,鼠标按键(可以提高工作效率) 1.选定文本自动复制到剪贴板 选择→将选定的文本自动复制到剪贴板(选上) 2.更高鼠标中间按钮和右键按钮的功 ...

  10. java heep space错误解决办法

    1.双击tomcat 2.Open launch configuration 3.Argument 4. VM arguments中添加:-Xmx1024M -Xms512M -XX:MaxPermS ...