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:大牛门来帮小弟看看呀,怎么就TLE了啊//我都求了模了

Posted by 526496390 at 2008-03-20 15:01:52 on Problem 1026
In Reply To:大牛门来帮小弟看看呀,怎么就TLE了啊//我都求了模了 Posted by:526496390 at 2008-03-20 15:01:41
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void trans(char a[210],int b[210],int n);

int main(void)
{
	int n;
	scanf("%d",&n);
	while(n!=0)
	{
	int huan=0;
	int times;
	int i;
	int change[210];
	char test[210];
	char mirror[210];
	for(i=0;i<n;i++)
		scanf("%d",&change[i]);
	scanf("%d",&times);
	while(times!=0)
	{
	getchar();
	gets(test);
	
	trans(test,change,n);
	strcpy(mirror,test);
	times--;
	while(times>0)
	{
	trans(test,change,n);
	times--;
	if(strcmp(test,mirror)!=0)
	{
		
		huan++;
	}
	else
	{
		times%=huan;
		times--;
	}
	}	
	while(test[n-1]==' ')
	{
		n--;
	}
	test[n]='\0';
	printf("%s\n",test);
	scanf("%d",&times);
	}
	scanf("%d",&n);
	}
	return 0;
}
void trans(char a[210],int b[210],int n)
{
	char temp[210];
	int i=(int)strlen(a);
	for(;i<=n;i++)
	{
		a[i]=' ';	
	}
	for(i=0;i<n;i++)
		temp[b[i]-1]=a[i];
	for(i=0;i<n;i++)
		a[i]=temp[i];
	a[i]='\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