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:好郁闷,老wa,大虾帮忙看一下,或用数据测一测,感激不尽,,,

Posted by xemoaya at 2005-09-21 09:18:55 on Problem 2615
In Reply To:好郁闷,老wa,大虾帮忙看一下,或用数据测一测,感激不尽,,, Posted by:fjnu_jxd_010 at 2005-09-21 01:04:46
> #include<iostream>
> #include<cmath>
> #include<string>
> using namespace std;
> int as(string w)
> {
> 	int i,flag=0;
> 	string k=w;
> 
> 	for(i=0;i<w.length();i++)
>           k[i]=w[w.length()-1-i];
> 
> if(k!=w)
> return 0;
> else return 1;
> 
> }
> int ts(int n,string a,string b,string &kkk,int &flag2)
> {
> 
> 	string t,hh;
> 	int flag=0,i,q;
> 	for(i=0;i<=n;i++)
> 	{
> 		   if(i==n)
> 		   {
> 				t=a.substr(0,i);//cout<<'sfds';
> 			for(q=i-1;q>=0;q--)
> 				t[i-1-q]=a[q];
> 			t[i-1-q]='\0';
> 	         hh=b+t;
> 			 if(as(hh)==0)
> 			 {kkk=t;//cout<<kkk<<endl;
> 			 }
> 			 else 	
> 			  flag2=1;
> 			 return 0;
> 		   }
> 		                                                                
> 		   flag=0 ;
> 	
> 			hh=a.substr(i);
> 			//cout<<hh<<endl;
> 			if(as(hh)==0)
> 				flag=1;
> 	
> 		//	cout<<flag<<endl;
> 		
> 	      if(flag==0)
> 		  {
> 			  
> 			  if(i==0&&as(b)==0)
> 			  {kkk="";break;}
> 			  else if(i==0&&as(b))
> 			  { flag2=1;continue;}
> 		     
> 				 t=a.substr(0,i);
>              
> 			for(q=i-1;q>=0;q--)
> 				t[i-1-q]=a[q];
> 			t[i-1-q]='\0';
> 			//
> 			
> 		  
>               hh=b+t;//cout<<hh.length()<<endl;//printf("%s\n",&hh[0]);//cout<<hh<<endl;
> 			  if(as(hh)==1)
> 			  {;}
> 			  else 
> 			  {kkk=t;return 0;}
> 			 
> 		 }   	
> 	}
> 		return 1;
> }		
> int main()
> {
> 	
> string a,sl,b,c,c2;
> //d="sf";sl=d+d;,d="abababa"cout<<sl.length()<<endl;
> char s[2000],w[2000];
> //if(as(d)==1)
> 
> 
> 	int n;//a="sers";cout<<as(a);
> 	while(gets(s))
> 	{	
> 	       gets(w);
> 
> 		a=s,b=w;n=a.length();
> 	//	if(as(a)&&as(b))
> 	//	{printf("\n");continue;}
> 		if(a.length()==0&&b.length()==0)
> 		{
> 		
> 			printf("No Solution.\n");continue;
> 		}
> 		else if(a.length()==0&&b.length()!=0)
> 	         if(as(b))
> 			 {
> 				 printf("No Solution.\n");continue;
>      
> 			 }
> 			 else 
> 			 {printf("\n");continue;}
> 		else if(a.length()!=0&&b.length()==0)
> 			if(as(a))
> 			{
> 				 printf("No Solution.\n");continue;
>      
> 			 }
> 			else  {printf("\n");continue;}
> int fla=0,fla2=0;
> 			 ts(n,a,b,c,fla);
> 	 
>      ts(n,b,a,c2,fla2);
> 	
> ///printf("%s\n",&c[0]);
> 	 if(fla==1&&fla2==1)
>          	 printf("No Solution.\n");
> 	 else if(fla==1&&fla2==0)
> 		 printf("%s\n",&c2[0]);
> 	 else if(fla==0&&fla2==1)
> printf("%s\n",&c[0]);
> 	 else 
> 		 if(c.length()<c2.length())
>            printf("%s\n",&c[0]);
> 		 else if(c.length()>c2.length())
>                  printf("%s\n",&c2[0]);
> 		 else if(c<=c2)
>              printf("%s\n",&c[0]);
> 		 else 
>       printf("%s\n",&c2[0]);
> 
> 	}
> 	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