"Bzoj 1090" [SCOI2003] string folding

Source: Internet
Author: User

Description

The definition of folding is as follows: 1. A string can be seen as its own folding. Remember it as s? S 2. X (S) is the folding of the string of X (x>1) s connected together. Remember as X (S)? SSSS ... s (x s). 3. What if a? A ', B? B ', then AB? A ' B ' For example, because 3 (a) = AAA, 2 (B) = BB, so 3 (a) C2 (b)? AAACBB, and 2 (3 (A) C) 2 (B)? AAACAAACBB gives a string to the shortest fold. For example, the shortest folding of the AAAAAAAAAABABABCCD is: 9 (A) 3 (AB) CCD.

Input

Only one line, the string s, guarantees a length of not more than 100.

Output

Only one line, that is, the shortest folding length.

Sample InputNeercyesyesyesneercyesyesyesSample Output -HINT

One of the shortest folds is: 2 (NEERC3 (YES))

is the interval type DP, and then did not introduce the equation, if my DP is not general weak Ah, HHH

F[I][J] = shortest length

F[i][j]=min (F[i][k]+f[k+1][j])//not explained

F[i][j]=min (F[i][k]+cal ((j-k)/(k-i+1) +1)//If j-k is k-i+1 n times ...

1#include <cstdio>2#include <iostream>3#include <cstring>4 using namespacestd;5 intf[ the][ the];6 Chars[ the];7 BOOLJudgeintLintRintllintRR) {8     if((r-l+1)% (rr-ll+1))return 0;9      for(inti=l;i<=r;i++)if(s[i]!=s[(i-l)% (rr-ll+1) +ll])return 0;Ten     return 1; One } A   - intCalcintx) { -     intt=0; the      while(x) { -t++; X/=Ten; -     } -     returnT; + } -   + intdpintLintR) { A     if(L==R)return 1; at     if(f[l][r]!=-1)returnF[l][r]; -     intTmp= (r-l+1); -      for(inti=l;i<r;i++) Tmp=min (TMP,DP (l,i) +DP (i+1, R)); -      for(inti=l;i<r;i++) -     if(Judge (i+1, r,l,i)) -Tmp=min (TMP,DP (l,i) +2+calc (r-i)/(i-l+1)+1)); inf[l][r]=tmp; -     returntmp; to } +   - intMain () { thescanf"%s", s+1); *     intLen=strlen (s+1); $memset (f,-1,sizeof(f));Panax Notoginsengprintf"%d", DP (1, Len)); -}

"Bzoj 1090" [SCOI2003] string folding

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.