hdu--4148--Length of S(n)
#include<iostream> #include<string> #include<cstring> void priTable(); using namespace std; int arr[30]; int main() { int n; priTable(); while(cin>>n && n!=0){ cout<<arr[n-1]<<endl; } return 0; } void priTable(){ arr[0]=1; string s="1"; int count=1; string next=""; for(int i=1;i<=29;++i) { for(int j=0;j<s.length();){ char temp=s[j]; int num=0; while(s[j]==temp){ j++;num++; } next+='0'+num; next+=temp; } arr[i]=next.length(); s=next; next=""; } }