Page 4 of 6

Posted: Wed Jan 17, 2007 6:10 am
by tgoulart
Actually, my program stops when 125 is reached. It is the halt instruction, so the program finishes there, and the subsequent lines should be ignored. This way we have 5 instructions executed, including the 125.

Posted: Wed Jan 17, 2007 11:46 pm
by Bandrosh
u have accepted? in ur question?
hehe thnks man, i

Posted: Thu Jan 18, 2007 1:01 am
by Bandrosh
Bandrosh wrote:u have accepted? in ur question?
hehe thnks man, now i have win one Sig Error heheh Ipm staying more crazy

Posted: Thu Jan 18, 2007 5:09 am
by tgoulart
Yes, I got accepted and I hardly doubt that cases like this one would be in the judge's input, unless it's the last case, because of the lines that you have to ignore.

Try to recode your program, you might have done some mistakes, and don't forget that all results are mod 1000!

Posted: Thu Jan 18, 2007 11:48 pm
by Bandrosh
pois

Posted: Sat Jan 20, 2007 3:46 pm
by tgoulart
I hardly doubt that cases like this one would be in the judge's input
Sorry, I didn't noticed that I store all the data before calculating, so It's not true...

10033

Posted: Tue Mar 20, 2007 3:23 pm
by Q.Qnick
here is my code
how can i solve the problem of time limit

#include<stdio.h>

int s,i,j;
int RAM[20][3],REG[10],ans;
char save[6];
main(){
scanf("%d\n",&s);
j=0;
for(i=0;i<s;i++){
j=0;
while(gets(save)){
if(!save[0])break;
if(save[0]=='0'&& save[1]=='0' &&save[2]=='0')
break;
RAM[j][0]=save[0]-'0';
RAM[j][1]=save[1]-'0';
RAM[j][2]=save[2]-'0';
j++;

}
for(;j<20;j++){
RAM[j][0]=0;
RAM[j][1]=0;
RAM[j][2]=0;
}
for(ans=0,j=0;;){
if(RAM[j][0]==1)
{
ans++;
break;
}
else if(RAM[j][0]==2)
{
REG[ RAM[j][1] ] = RAM[j][2];
}
else if(RAM[j][0]==3)
{
REG[ RAM[j][1] ] += RAM[j][2];
REG[ RAM[j][1] ]%=1000;
}
else if(RAM[j][0]==4)
{
REG[ RAM[j][1] ] *= RAM[j][2];
REG[ RAM[j][1] ]%=1000;
}
else if(RAM[j][0]==5)
{
REG[ RAM[j][1] ] = REG[ RAM[j][2] ];
}
else if(RAM[0]==6)
{
REG[ RAM[j][1] ] += REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
}
else if(RAM[j][0]==7)
{
REG[ RAM[j][1] ] *= REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
}
else if(RAM[j][0]==8)
{
REG[ RAM[j][1] ] = RAM[j][ REG[ RAM[j][2] ] ];
}
else if(RAM[j][0]==9)
{
RAM[j][ REG[ RAM[j][2] ] ] = REG[ RAM[j][1] ];
}
else if(RAM[j][0]==0 && REG[ RAM[j][2] ]!=0)
{
j = REG[ RAM[j][1] ];
}
ans++;
j++;
}
printf("%d\n",ans);
if(i!=s-1){
printf("\n");
}
}
}

Posted: Tue Mar 20, 2007 4:35 pm
by Q.Qnick
some body help me T.T

Posted: Wed Mar 21, 2007 2:42 pm
by Q.Qnick
i do some change , but it isn't work .
can some one let me know where is the plb.
thx a lot .



#include<stdio.h>

int s,i,j,k;
int RAM[1000][3],REG[10]={0},ans;
char save[6];
main(int argc,char *argv[]){
/*FILE *fp;
fp=fopen(argv[1],"r");*/
fscanf(stdin,"%d\n",&s);
/*printf("%d\n",s);*/
j=0;
for(i=0;i<s;i++){
j=0;
while(fgets(save,6,stdin)!=NULL){
if(save[0]=='\n')
{
break;
}
else
{
RAM[j][0]=save[0]-'0';
RAM[j][1]=save[1]-'0';
RAM[j][2]=save[2]-'0';
j++;
}
}
for(k=j;k<1000;k++){
RAM[k][0]=0;
RAM[k][1]=0;
RAM[k][2]=0;
}
/*for(k=0;k<j;k++){
printf("%d %d %d %d\n",i,RAM[k][0],RAM[k][1],RAM[k][2]);
}
printf("\n==\n");*/

for(k=0;k<10;k++){
REG[k]=0;
}

ans=0;
for(j=0;;){
if(RAM[j][0]==1)
{
ans++;
break;
}
else if(RAM[j][0]==2)
{
REG[ RAM[j][1] ] = RAM[j][2];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==3)
{
REG[ RAM[j][1] ] += RAM[j][2];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==4)
{
REG[ RAM[j][1] ] *= RAM[j][2];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==5)
{
REG[ RAM[j][1] ] = REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==6)
{
REG[ RAM[j][1] ] += REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==7)
{
REG[ RAM[j][1] ] *= REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==8)
{
REG[ RAM[j][1] ] = RAM[j][ REG[ RAM[j][2] ] ];
j++;
}
else if(RAM[j][0]==9)
{
RAM[j][ REG[ RAM[j][2] ] ] = REG[ RAM[j][1] ];
j++;
}
else if(RAM[j][0]==0)
{
if(REG[ RAM[j][2] ]!=0)
{
j = REG[ RAM[j][1] ];
}
else
{
j++;
}
}
if(j==1000){
j=0;
}
ans++;
}
printf("%d\n",ans);
if(i!=s-1){
printf("\n");
}
}
}

Posted: Wed Mar 21, 2007 3:23 pm
by helloneo

Help me! Input code?

Posted: Wed Mar 21, 2007 4:03 pm
by pbfox
Help me! Input Code?

Input:

Code: Select all

2

299
492
495
399
492
495
399
283
279
689
078
100
000
000
000

456
789
234
453
125
175
183
256
012
100
000

Re: 10033 - Interpreter - I need a multi-testcase input

Posted: Wed Mar 21, 2007 4:14 pm
by pbfox
:cry: my code is wrong, but anyway...
help me,please!

Posted: Wed May 09, 2007 7:02 pm
by Bandrosh
sim gourlat to precisando de ajuda, agora q terminou o semestre v

Posted: Thu Jul 05, 2007 3:00 am
by hardcode
tgoulart wrote:Actually, my program stops when 125 is reached. It is the halt instruction, so the program finishes there, and the subsequent lines should be ignored. This way we have 5 instructions executed, including the 125.
Why does your program stop when 125 is reached tgoulart? Isn't 100 mean to be the halt instruction? I'm confused. Thanks for your time!

Posted: Thu Jul 05, 2007 4:28 am
by tgoulart
hardcode wrote:
tgoulart wrote:Actually, my program stops when 125 is reached. It is the halt instruction, so the program finishes there, and the subsequent lines should be ignored. This way we have 5 instructions executed, including the 125.
Why does your program stop when 125 is reached tgoulart? Isn't 100 mean to be the halt instruction? I'm confused. Thanks for your time!
My program stops because I verify the instruction by the first digit, and 1 is the halt operation. But if you take a look at the table, you will see that 125 isn't a valid instruction.