题目

字符串处理

题意要猜,解析见代码:

/*
这题每个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. git传输协议原理

    git精神:distributed-is-the-new-centralized 转自:http://git-scm.com/book/zh/v1/Git-%E5%86%85%E9%83%A8%E5% ...

  2. mq消息队列

    rabbitmq学习9:使用spring-amqp发送消息及同步接收消息 通过对spring-amqp看重要类的认识,下面来通过spring-amqp的发送消息及同步接收消息是如何实现的.有兴趣的朋友 ...

  3. 浅谈Objective-C异常处理

    -----<a href="http://www.itheima.com" target="blank">Java培训.Android培训.iOS培 ...

  4. poj 2485 Highways

    题目连接 http://poj.org/problem?id=2485 Highways Description The island nation of Flatopia is perfectly ...

  5. mysql查看日志

    工具:mysqlbinlog, 在bin目录中日志在data目录中 日志过滤:mysqlbinlog mysql-bin.000011 | less mysqlbinlog mysql-bin.000 ...

  6. Mysql 更改最大连接数

    方法一: 进入MySQL安装目录 打开MySQL配置文件 my.ini 或 my.cnf查找 max_connections=100 修改为 max_connections=1000 服务里重起MyS ...

  7. OC中类的扩展介绍

    对OC类的扩展总结如下: 共有4个: 1.子类 subClass 作用:可以使用类的继承来增添父类的变量和方法. 写法:在.h文件中 @interface Student : Person 2.分类 ...

  8. scjp考试准备 - 4 - 关于数组

    好吧这道题我丢脸了,竟然做错了. 如下程序的输出结果是: class Alligator{ public static void main(String[] args){ int[]x[] = {{1 ...

  9. scjp考试准备 - 3 - 关于Arrays

    判断如下程序的最终输出值: import java.util.*; public class Quest{ public static void main(String[] args){ String ...

  10. [转]JSON与XML的区别比较

    1.定义介绍 (1).XML定义扩展标记语言 (Extensible Markup Language, XML) ,用于标记电子文件使其具有结构性的标记语言,可以用来标记数据.定义数据类型,是一种允许 ...