Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:这年月连模拟题都tle的莫名其妙了

Posted by dddpppbox at 2005-10-15 16:41:56 on Problem 2410
In Reply To:这年月连模拟题都tle的莫名其妙了 Posted by:anonym11 at 2005-09-07 01:14:12
```#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
using namespace std;
char inter[32];
char accu,pc;
char a[10];
inline void init();
inline void sta(int n);
inline void lda(int n);
inline void beq(int n);
inline int a_to_n();
inline void dec();
inline void inc();
inline void jmp(int n);
int main()
{
while(gets(a))
{
while(a[0]=='\0')
{
gets(a);
}
init();
for(int i=0;i<8;i+=1)
{
if(a[i]=='1')
inter[0] |= 1<<(7-i);
}
for(int i=1;i<32;i+=1)
{
gets(a);
for(int j=0;j<8;j+=1)
{
if(a[j]=='1')
{
inter[i]|=1<<(7-j);
}
}
}
unsigned tmp;
unsigned t;
tmp=0xe0;
bool flag=true;
while(flag)
{
int n=a_to_n();
switch((tmp & inter[n]))
{
case 0: sta(n);
break;
case 0x20: lda(n);
break;
case 0x40: beq(n);
break;
case 0x60:
break;
case 0x80:
dec();
break;
case 0xa0:
inc();
break;
case 0xc0:
jmp(n);
break;
case 0xe0:
flag=false;
break;

}
tmp=0xe0;
}
for(int i=0;i<8;i+=1)
{
if(accu & 1 << (7-i)) cout<<1;
else cout<<0;
}
cout<<endl;
}
return 0;
}
inline int a_to_n()
{
int n;
n=pc;
return n;
}
{
pc+=1;
return;
}
inline void jmp(int n)
{
char x=0;
x|=inter[n];
x&=0x1f;
pc=x;
return;
}
inline void inc()
{
accu+=1;
return;
}
inline void dec()
{
accu-=1;
return;
}
inline void beq(int n)
{
if(!accu)
{
char x=0;
x|=inter[n];
x&=0x1f;
pc=x;
}
return;
}
inline void lda(int n)
{
int num=0;
num |= inter[n];
num &= 0x1f;
accu=inter[num];
return;
}
inline void sta(int n)
{
int num=0;
num |=inter[n];
num &= 0x1f;
inter[num]=accu;
return;
}
inline void init()
{
memset(inter,0,sizeof(inter));
// memset(a,0,sizeof(a));
accu=0;
pc=0;
return;
}

Followed by: