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:大家帮帮忙啊。。我这程序老超时。。汗,这年头模拟还有超时说的

Posted by ustcxiaofeng at 2009-03-12 10:43:49 on Problem 1049
In Reply To:大家帮帮忙啊。。我这程序老超时。。汗,这年头模拟还有超时说的 Posted by:yzhw at 2009-02-23 12:15:32





case6 和case7的代码写错了吧,应该是下面的

case 6:
if(!a){
 i=line[i+1]*16+line[i+2];
 }
else i+=3;;
  break;

case 7:
 i=line[i+1]*16+line[i+2];
 break;















> # include <iostream>
> using namespace std;
> int main()
> {
> 	while(1)
> 	{
> 		char line[256];
> 		bool flag=true;
> 		int i,a=0,b=0,t;
> 		for(i=0;i<256;i++) 
> 		{
> 			cin>>line[i];
> 			if(line[i]>=65) line[i]-=55;
> 			else line[i]-=48;
> 		}
> 		if(line[0]==8) break;
> 		i=0;
> 		while(i<256&&flag)
> 		{
> 		  switch(line[i])
> 		  {
> 		  case 0:
> 			  a=line[line[i+1]*16+line[i+2]];
> 			  i+=3;
> 			  break;
> 		  case 1:
> 			  line[line[i+1]*16+line[i+2]]=a;
> 			  i+=3;
> 			  break;
> 		  case 2:
> 			  t=a;
> 			  a=b;
> 			  b=t;
> 			  i++;
> 			  break;
> 		  case 3:
> 			  t=a+b;
> 			  a=t%16;
> 			  b=t/16;
> 			  i++;
> 			  break;
> 		  case 4:
> 			  a++;
> 			  if(a==16) a=0;
> 			  i++;
> 			  break;
> 		  case 5:
> 			  a--;
> 			  if(a==-1) a=15;
> 			  i++;
> 			  break;
> 		  case 6:
> 			  if(!a)
> 			  {
> 
> 			  i=line[i+1]*16+line[i+2];
> 			  i+=3;
> 			  }
> 			  else i++;
> 			  break;
> 		  case 7:
> 			  i=line[i+1]*16+line[i+2];
> 			  i+=3;
> 			  break;
> 		  case 8:
> 			  flag=false;
> 			  break;
> 		  };
> 		}
> 		for(i=0;i<256;i++)
> 		{
> 			if(line[i]<=9) printf("%d",line[i]);
> 			else if(line[i]==10) printf("A");
> 			else if(line[i]==11) printf("B");
> 			else if(line[i]==12) printf("C");
> 			else if(line[i]==13) printf("D");
> 			else if(line[i]==14) printf("E");
> 			else printf("F");
> 		}
> 		printf("\n");
> 	}
> 	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