http://codeforces.com/problemset/problem/701/A
题意:
好多人一块打扑克牌,存在部分两张牌的和相等,问都是哪两张的和与另外两张的和等值。
思路:
统计总和取平均,最后暴力!宇神说了,会暴力是最 low 的%%%%%%%%%%
Code:
#include<stdio.h>
#include<cstring>
const int MYDD=1103;
int c[MYDD];
bool vis[MYDD];//标记该牌是否还存在
int main() {
int n;
while(scanf("%d",&n)!=EOF) {
int sum=0;
for(int j=1; j<=n; j++) {
scanf("%d",&c[j]);
sum+=c[j];
}
memset(vis,false,sizeof(vis));
int a=sum/(n/2);//每个人应该获得的点数
for(int j=1; j<=n; j++) {
for(int k=1; k<=n; k++) {
if(j==k) continue;//一张牌
if(vis[j]||vis[k]) continue;//存在一张牌已经被使用
if(c[j]+c[k]==a) {
printf("%d %d\n",j,k);
vis[j]=vis[k]=true;
}
}
}
}
return 0;
}