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

就算不WA,都会TLS,我的跟你的思路差不多

Posted by fortunato at 2008-01-22 11:05:39 on Problem 1047
In Reply To:哪位给提供几组测试数据,题里的数据都通过了,还是WA!谢谢! Posted by:hbu06_194 at 2006-08-22 16:42:53
> #include <iostream>
> #include <algorithm>
> using namespace std;
> #include <stdio.h>
> 
> int main()
> {
> 	char a[64],c[128],b[64],p[64];
> 	int i,j,k,m,l,num,s,data,len1,len2;
> 	cin>>a;
> 	len1=strlen(a);
> 	strcpy(p,a);
> 	sort(p,p+len1);
> 	data=len1;
> 	while(1)
> 	{
> 		num=data;
> 		for(i=0;i<=2*len1+1;i++)
> 	    	c[i]='0';
> 		i=0;
> 		while(num)
> 		{
> 			b[i]=num%10+'0';
> 			i++;
> 			num=num/10;
> 		}
> 		len2=i;
> 		m=0;
> 		for(i=0;i<len2;i++)
> 		{
> 			k=m;
> 			for(j=len1-1;j>=0;j--)
> 			{
> 				s=(a[j]-'0')*(b[i]-'0')+(c[k]-'0')+'0';
> 				l=k;
> 				if(s-'0'>=10)
> 				{
> 				    	while(s-'0'>=10)
> 						{
> 		    		    	c[l+1]=(c[l+1]-'0')+(s-'0')/10+'0';
> 			     	    	c[l]=(s-'0')%10+'0';
> 		    	  	    	l++;
> 			    	    	s=c[l];
> 						}
> 				}
> 				else c[k]=s;
> 				k++;
> 			}
> 			m++;
> 		}
> 		i=2*len1;
> 		while(c[i]=='0')
> 			i--;
> 		c[i+1]='\0';
> 		if(i+1<len1)
> 		{
> 			while(i+1<len1)
> 			{
> 				for(j=i+1;j>=0;j--)
> 		    		c[j+1]=c[j];
>                 c[0]='0';
>      			i++;
> 	     		sort(c,c+i+1);
> 			}
> 		}
> 		else sort(c,c+i+1);
> 		if(strcmp(c,p)!=0)
> 		{
> 			cout<<a<<" is not cyclic"<<endl;
> 			return 0;
> 		}
>         data--;
> 		if(data==0)
> 		{
> 			cout<<a<<" is cyclic"<<endl;
> 			return 1;
> 		}
> 	}
> }

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