Cod sursa(job #658814)

Utilizator dutzulBodnariuc Dan Alexandru dutzul Data 9 ianuarie 2012 17:10:46
Problema Congr Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
#include <algorithm>
#define l 1000000
using namespace std;
ifstream f("congr.in");
ofstream g("congr.out");
long long  p,i,v[l],r[l],s,j;
int main(){
  f>>p;
  for(i=1; i<=2*p-1; i++) f>>v[i];
  for(i=1; i<=p; i++) r[i]=1;
  for(;;){
      random_shuffle(r+1,r+2*p);
      for(j=1; j<=2*p-1; j++)
        if (r[j]==1) s+=v[j];
      if (s%p==0){
          for(j=1; s&&j<=2*p-1; j++)
            if (r[j]==1) g<<j<<" ";
          break;
        }
      s=0;
    }
  g<<'\n';
  f.close();
  g.close();
  return 0;
}