Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  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 void add();
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);
                                        add();
                                        break;
                                case 0x20: lda(n);
                                        add();
                                        break;
                                case 0x40: beq(n);
                                        break;
                                case 0x60:
                                        add();
                                        break;
                                case 0x80:
                                        add();
                                        dec();
                                        break;
                                case 0xa0:
                                        inc();
                                        add();
                                        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;
}
inline void add()
{
        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:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator