Pagini recente »
lasm_03_03_2020_cl_12b_c_a
|
Cod sursă (job #334632)
|
Monitorul de evaluare
|
Atașamentele paginii Clasament tema03-juniori-2014-2015
|
Cod sursă (job #107814)
Cod sursă (job
#107814)
#include <stdio.h>
#define MAXL 100000
FILE *in;
char p;
int v[MAXL];
inline void nextch(){
p = fgetc(in);
while(p == ' ')
p = fgetc(in);
}
inline int getnum(){
int x = 0;
while(p >= '0' && p <= '9'){
x *= 10;
x += p - '0';
nextch();
}
return x;
}
int eval(int st){
int x = getnum(), nr = 0;
while(p == '('){
while(p != ')'){
nextch();
v[st + nr] = eval(st + nr);
nr++;
}
x = v[st + (x - 1) % nr];
nr = 0;
nextch();
}
return x;
}
int main(){
in = fopen("bizar.in", "r");
FILE *out = fopen("bizar.out", "w");
nextch();
fprintf(out, "%d", eval(0));
fclose(in);
return 0;
}