| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
TLE难道不是模拟吗?
#include <iostream.h>
#include <string.h>
int m[33],pc,accu,c,x;
void in()
{
char str[10];
memset(m,0,sizeof(m));
for(int i=0;i<32;++i)
{
cin>>str;
for(int j=7;j>=0;--j)
m[i] = m[i]*2 + str[7-j]-'0';
}
accu = 0;
pc = 0;
}
void sol()
{
while(1){
if(pc>=32)
pc-=32;
c = m[pc++];
x = c&31;
switch(c>>5)
{
case 0:
m[x] = accu;
break;
case 1:
accu = m[x];
break;
case 2:
if(accu==0)
pc = x;
break;
case 3:
break;
case 4:
--accu;
if(accu < 0)
accu+=256;
break;
case 5:
++accu;
if(accu>=256)
accu-=256;
break;
case 6:
pc = x;
break;
case 7:
return ;
}
}
}
void out(int n)
{
char str[10];
memset(str,0,sizeof(str));
for(int i=0;i<8;++i)
if(n&(1<<i))
str[7-i] = '1';
else
str[7-i] = '0';
cout<<str<<endl;
}
void main()
{
while(cin)
{
in();
sol();
out(accu);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator