Topic Links:
A. Cards
Test instructions
Ask two numbers and the same, how to combine;
AC Code:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include < cmath> #include <bits/stdc++.h> #include <stack>using namespace std; #define for (i,j,n) for (int i=j;i< =n;i++) #define MST (SS,B) memset (ss,b,sizeof (ss)); typedef long LONG ll;template<class t> void Read (T&num) {C Har CH; BOOL F=false; For (Ch=getchar (); ch< ' 0 ' | | Ch> ' 9 '; f= ch== '-', Ch=getchar ()); for (num=0; ch>= ' 0 ' &&ch<= ' 9 '; num=num*10+ch-' 0 ', Ch=getchar ()); F && (num=-num);} int stk[70], tp;template<class t> inline void print (T p) {if (!p) {puts ("0"); return;} while (p) stk[++ TP] = p%10, p/=10; while (TP) Putchar (stk[tp--] + ' 0 '); Putchar (' \ n ');} Const LL Mod=1e9+7;const double Pi=acos ( -1.0); const int INF=1E9;CONST int N=1e5+10;const int Maxn=500+10;const double eps= 1e-6;int N,a[200],vis[200];int Main () {int n; Read (n); int sum=0; for (i,1,n) read (A[i]), sum+=a[i]; INT le=2*sum/n; for (I,1,n) {if (vis[i]) continue; for (J,1,n) {if (!vis[j]&&a[i]+a[j]==le&&i!=j) { cout<<i<< "" <<j<<endl; Vis[i]=1; Vis[j]=1; Break }}} return 0;}
Codeforces 701A A. Cards (water problem)