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

精简代码~吐糟一下,poj貌似不能用strrev~只能reverse了~

Posted by xc19881023 at 2016-06-12 21:34:49 on Problem 2541
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,L,top;
char a[1010000],p[20];

int main()
{	 
//	freopen("D:\\input.txt","r",stdin);
//	freopen("D:\\output1.txt","w",stdout);
	scanf("%d%d%s",&n,&L,a+1005);
	reverse(a+1005,a+1005+n);
	while (top<L) 
	{	
		char *c;
		int i;
		for ( i = 13; i  ; i--)
		{		
			memcpy(p,a+1005-top,i);
			p[i]='\0';		
			if (c=strstr(a+1006-top,p)) break;
		}		
		a[1005-++top]=i?*(c-1):'0';		
	}
	a[1005]='\0';
	reverse(a+1005-top,a+1005);
	puts(a+1005-top);
	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