Cod sursa(job #658802)

Utilizator dutzulBodnariuc Dan Alexandru dutzul Data 9 ianuarie 2012 16:58:26
Problema Congr Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <fstream>
#include <algorithm>
#define l 700000
using namespace std;
ifstream f("congr.in");
ofstream g("congr.out");
int 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(i=1; i<=300; i++)
    {
      random_shuffle(r+1,r+2*p);

      for(j=1; j<=2*p-1; j++)
        if (r[j]==1) s+=v[i];

      if (s%p==0)
        {
          for(j=1; s&&j<=2*p-1; j++)
            if (r[j]==1) g<<j<<" ";
          break;
        }

      s=0;
    }

  f.close();
  g.close();
  return 0;
}