Mai intai trebuie sa te autentifici.
Cod sursa(job #723946)
| Utilizator | Data | 26 martie 2012 08:23:17 | |
|---|---|---|---|
| Problema | Stramosi | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <stdio.h>
unsigned N,M,O[250001],T,R;
int main()
{ FILE *f=fopen("stramosi.in","r");
fscanf(f,"%u %u",&N,&M);
for (unsigned i=1;i<=N;i++)
fscanf(f,"%u",&O[i]);
FILE *g=fopen("stramosi.out","w");
while(M)
{ fscanf(f,"%u %u",&T,&R);
O[0]=O[T];
R--;
while(R)
{ O[0]=O[O[0]];
R--;
}
fprintf(g,"%u\n",O[0]);
M--;
}
fclose(g);
fclose(f);
}
