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:为什么一直在 Time Limit Exceeded

Posted by timeoutle at 2011-05-15 21:07:47 on Problem 1049
In Reply To:为什么一直在 time limited Posted by:timeoutle at 2011-05-15 21:07:06
> #include<iostream>
> #include<string>
> #include<cmath>
> #include<algorithm>
> using namespace std;
> char mem[256];
> char ss[17]="0123456789ABCDEF";  
> int main( )
> {
> 	char a, b,ch;
> 	int i,num;
> 	bool flag;
> 	while ( true ){
> 		for ( i=0; i<256; i++ )
> 			if(scanf("%c",&mem[i])==EOF)
> 				return 0;
> 		scanf("%c",&ch);
> 		for ( i=0; i<256; i++ )
>         {
>             mem[i] -= 48;                                                
>             if(mem[i] > 9)
>                mem[i] -= 7;
>         }
> 		if( mem[0] == 8 )
> 			break;
> 		num = 0;
> 		flag = true;
> 		while ( flag ){
> 			switch ( mem[num++] ){
> 				case 0:
> 					a = mem[( mem[num] << 4 ) + mem[num+1]];
> 					num+=2;
> 					break;
> 				case 1:
> 					mem[( mem[num] << 4 ) + mem[num+1]] = (a &= 15);
> 					num+=2;
> 					break;
> 				case 2:
> 					swap(a,b);
> 					break;
> 				case 3:
> 					a+=b;
>                     b=a>>4;
> 					break;
> 				case 4:
> 					a++;
> 					break;
> 				case 5:
> 					a--;
> 					break;
> 				case 6:
>                     if((a&=15)!=0)
>                     {
>                         num+=2;
>                         break;
>                     }
> 					break;
> 				case 7:
> 					num=((mem[num]<<4)+mem[num+1]); 	
> 					break;
> 				case 8:
> 					flag = false;
> 			}
> 		}
>         for(i=0;i<256;i++)
>           printf("%c",ss[mem[i]]);	
> 		printf("\n");
> 	}	
> 	system("pause");
> 	return 0;
> }

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