Hdu 2594 Simpsons ' Hidden talents

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=2594

Idea: Concatenate two to find the next array is the sum of the two, the length of the traverse should be less than the minimum value of two strings

1#include <cstdio>2#include <iostream>3#include <algorithm>4#include <math.h>5#include <string.h>6#include <vector>7#include <queue>8#include <iterator>9#include <vector>Ten#include <Set> One #defineDinf 0x3f3f3f3f AtypedefLong Longll; - //const int max= (1<<16) +10; - using namespacestd; the    - Const intmax=50000+Ten;  - Chars1[max*2],s2[max];  - intnext[max*2];  +    - voidGet_next (Char*a) {   +     inti=-1, j=0, len=strlen (a);  Anext[0]=-1;  at      while(j<Len) {   -         if(i = =-1|| A[i] = = A[j]) next[++j]=++i;  -         ElseI=Next[i];  -     }   -     return;  - }   in    - intMain () { to      while(cin>>s1>>S2) {   +         intLena=strlen (S1), Lenb=strlen (S2), len=lena+LenB;  - strcat (S1,S2);  the Get_next (S1);  *          while(Next[len]>lena | | NEXT[LEN]&GT;LENB) len=Next[len];  $len=Next[len]; Panax Notoginseng          for(intI=0; i<len;++i) cout<<S1[i];  -         if(len) cout<<' ';  thecout<<len<<Endl;  +     }   A     return 0;  the}

Hdu 2594 Simpsons ' Hidden talents

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.