题目

字符串处理

题意要猜,解析见代码:

/*
这题每个S(n)是描述S(n-1)值
例如:
S(1)=1;
S(2)=11;即描述S(1)有1个1=11
S(3)=21;即描述S(2)有2个1=21
S(4)=1211;即描述S(3)有1个2和2个1=1211
....
*/ #include <cstdio>
#include<iostream>
#include <cstring>
#include <algorithm>
using namespace std;
struct tt
{
int nu[];
int n;
}a[]; int main() {
a[].n=;
a[].nu[]=;
for(int i=;i<;i++){
int num=,pre=a[i-].nu[],idd=;
for(int j=;j<a[i-].n;j++){
if(pre!=a[i-].nu[j]){ int tep[],id=;
while(num!=){
tep[id++]=num%;
num=num/;
}
for(int ii=id-;ii>=;ii--){
a[i].nu[idd++]=tep[ii];
}
a[i].nu[idd++]=a[i-].nu[j-];
num=;
pre=a[i-].nu[j];
}
else {
num++;
}
}
int tep[],id=;
while(num!=){
tep[id++]=num%;
num=num/;
}
for(int ii=id-;ii>=;ii--){
a[i].nu[idd++]=tep[ii];
}
a[i].nu[idd++]=a[i-].nu[a[i-].n-];
a[i].n=idd;
}
int n;
while(scanf("%d",&n),n)
{
cout << a[n].n <<endl;
}
return ;
}

HDU 4148 Length of S(n)(字符串)的更多相关文章

  1. HDU 2087 剪花布条 (字符串哈希)

    http://acm.hdu.edu.cn/showproblem.php?pid=2087 Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图 ...

  2. [LeetCode] Encode String with Shortest Length 最短长度编码字符串

    Given a non-empty string, encode the string such that its encoded length is the shortest. The encodi ...

  3. HDU 11488 Hyper Prefix Sets (字符串-Trie树)

    H Hyper Prefix Sets Prefix goodness of a set string is length of longest common prefix*number of str ...

  4. hdu 5469 Antonidas(树的分治+字符串hashOR搜索+剪枝)

    题目链接:hdu 5469 Antonidas 题意: 给你一颗树,每个节点有一个字符,现在给你一个字符串S,问你是否能在树上找到两个节点u,v,使得u到v的最短路径构成的字符串恰好为S. 题解: 这 ...

  5. 【LeetCode每天一题】Length of Last Word(字符串中最后一个单词的长度)

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...

  6. HDU 5442 后缀自动机(从环字符串选定一个位置 , 时针或顺时针走一遍,希望得到字典序最大)

    http://acm.hdu.edu.cn/showproblem.php?pid=5442 题目大意: 给定一个字符串,可理解成环,然后选定一位置,逆时针或顺时针走一遍,希望得到字典序最大,如果同样 ...

  7. 题解报告:hdu 1230 火星A+B(字符串)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1230 Problem Description 读入两个不超过25位的火星正整数A和B,计算A+B.需要 ...

  8. hdu 2072 1106学一波字符串分割,C语言与C++两种方法

    hdu2072:题意:输出给定字符串中的单词数(一个句子中可能有两个相同的单词),这里的思想是把每个单词取出来,放入set(这个集合容器中不允许有相同的元素)中,最后输出该集合的大小即可. 现在的问题 ...

  9. HDU 1880 魔咒词典(字符串哈希)

    题目链接 Problem Description 哈利波特在魔法学校的必修课之一就是学习魔咒.据说魔法世界有100000种不同的魔咒,哈利很难全部记住,但是为了对抗强敌,他必须在危急时刻能够调用任何一 ...

随机推荐

  1. Outlook打不开? 进程一大堆!

    问题描述: ====== 关闭Outlook应用程序后,Outlook.exe进程仍在任务管理器里继续运行,不能关闭. 原因: ====== Outlook的插件或者扩展程序阻止Outlook关闭 解 ...

  2. 019C#中使用移位运算符获取汉字编码值

    在进行移位运算时,当数值的二进制数每次向左移1位就相当于乘以2,当数值每次向右移一位就相当于除以2 private void button1_Click(object sender, EventArg ...

  3. ASP.NET2.0中对TextBox的Enable和ReadOnly属性的限制

    在以前的ASP.NET 1.x版本中,设置为ReadOnly的TextBox控件在客户端更改了值后,在服务器端仍然可以得到修改后的值,但在ASP.NET 2.0中,这种做法已经限制.这是为了提高应用程 ...

  4. C#之玩转反射【转:http://www.cnblogs.com/yaozhenfa/p/CSharp_Reflection_1.html】

    前言 之所以要写这篇关于C#反射的随笔,起因有两个:   第一个是自己开发的网站需要用到   其次就是没看到这方面比较好的文章. 所以下定决心自己写一篇,废话不多说开始进入正题. 前期准备 在VS20 ...

  5. ExpressJS File Uploading – GridFS – MongoDB

    n this blog post we will see how to handle multipart data/file uploading with expressjs. Save files ...

  6. mysql substring_index

    select * from tablename where substring_index(field1,'_',-1)=‘abc' #表中field1的值结构为123_abc

  7. 时隔3年半Spring.NET 2.0终于正式Release了

    一直很喜欢Spring.NET,不过2011年8月2日1.3.2正式release之后,再没有正式版本的release了. 直到4天前,Spring.NET 2.0 GA终于Release. http ...

  8. [转]分布式文件系统FastDFS架构剖析

    [转]分布式文件系统FastDFS架构剖析 http://www.programmer.com.cn/4380/ 文/余庆 FastDFS是一款类Google FS的开源分布式文件系统,它用纯C语言实 ...

  9. Controltemplate datatemplate

    DataTemplate ControlTemplate we can search many posts about this topic. some valuable link: DataTemp ...

  10. ABAP自定义类的构造方法

    REPORT ytest_011. *----------------------------------------------------------------------* * CLASS z ...