Cod sursa(job #451371)

Utilizator diannneeeHas Diana Alexandra diannneee Data 9 mai 2010 14:33:03
Problema Stramosi Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.29 kb
#include<fstream.h>
ifstream f("STRAMOSI.IN");
ofstream g("STRAMOSI.OUT");
long v[2500];
int main()
{long N,M,P,Q;
 f>>N>>M;
 int i;
 for(i=1;i<=N;i++)
    f>>v[i];
 for(i=1;i<=M;i++)
    {f>>Q>>P;
     int j;
     for(j=1;j<=P;j++)
	Q=v[Q];
     g<<Q<<endl;
    }
 return 0;
}