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

哪位大哥帮忙看看我的程序为什么会超时啊,help!!

Posted by project at 2004-11-09 21:02:38 on Problem 2015
时间复杂度只有O(lenC×lenS)没什么可能超啊,请指教!thx!

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int x,i,j,n,d,len,loop,k,m1,lenc,f1,f;char s[40],p[40],m[70],c[70];
	while(scanf("%d",&x)!=EOF){
		if(!x) break;
		memset(s,'\0',40);
		memset(p,'\0',40);
		memset(m,'\0',70);
		memset(c,'\0',70);
		scanf("%s%s%s",s,p,c);
		lenc=strlen(c);
		d=((int)(sqrt(lenc*lenc*lenc)+x))%lenc;
		lens=strlen(s);
		for(i=0;i<lens;i++)
			if(c[d]==s[i]) {n=i;break;}
		m[d]=p[n];
		loop=0;
		for(i=d;;i--){
			loop++;f=0;f1=0;
			for(j=0;j<lens;j++){
				if(!f&&s[j]==m[(i+5*lenc)%lenc]){n=j;f=1;}
				if(!f1&&s[j]==c[((i-1+5*lenc))%lenc]){m1=j;f1=1;}
				if(f&&f1) break;
			}
			k=m1^n;
			m[((i-1)+5*lenc)%lenc]=p[k];
			if(loop+1==lenc) break;
		}
		printf("%s\n",m);
	}
	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