Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
精简代码~吐糟一下,poj貌似不能用strrev~只能reverse了~#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator