#include #include #include #include #include #define ADD 1 #define DIV 2 #define DUP 3 #define MUL 4 #define SUB 5 FILE *in; int n=0,num=0; char lin[200]; int x[15],y[15],dups,max,len; int prog[20],empty,ret,stack[50]; int run (int len,int x) { int i; int sp=0; stack[0]=x; for (i=1;i<=len;i++){ if (prog[i]==ADD) { stack[sp-1]=stack[sp]+stack[sp-1]; if (abs(stack[sp-1])>30000) {return 99999;}; sp--; } if (prog[i]==DIV) { if (stack[sp]){ stack[sp-1]=stack[sp-1]/stack[sp]; if (abs(stack[sp-1])>30000) {return 99999;}; sp--; }else return 99999; } if (prog[i]==DUP) { stack[sp+1]=stack[sp]; sp++; } if (prog[i]==MUL) { stack[sp-1]=stack[sp]*stack[sp-1]; if (abs(stack[sp-1])>30000) {return 99999;}; sp--; } if (prog[i]==SUB) { stack[sp-1]=stack[sp-1]-stack[sp]; if (abs(stack[sp-1])>30000) {return 99999;}; sp--; } } if (sp==0) {return stack[sp];}else{return 99999;} } int test(int len) { int i; for (i=0;i