Fibonacci String

Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5012 Accepted Submission(s):
1693

Problem Description
After little Jim learned Fibonacci Number in the class
, he was very interest in it.
Now he is thinking about a new thing --
Fibonacci String .

He defines : str[n] = str[n-1] + str[n-2] ( n > 1 )

He is so crazying that if someone gives him two strings str[0] and
str[1], he will calculate the str[2],str[3],str[4] , str[5]....

For
example :
If str[0] = "ab"; str[1] = "bc";
he will get the result ,
str[2]="abbc", str[3]="bcabbc" , str[4]="abbcbcabbc" …………;

As the string
is too long ,Jim can't write down all the strings in paper. So he just want to
know how many times each letter appears in Kth Fibonacci String . Can you help
him ?

 
Input
The first line contains a integer N which indicates the
number of test cases.
Then N cases follow.
In each case,there are two
strings str[0], str[1] and a integer K (0 <= K < 50) which are separated
by a blank.
The string in the input will only contains less than 30 low-case
letters.
 
Output
For each case,you should count how many times each
letter appears in the Kth Fibonacci String and print out them in the format
"X:N".
If you still have some questions, look the sample output
carefully.
Please output a blank line after each test case.

To make
the problem easier, you can assume the result will in the range of int.

 
Sample Input
1
ab bc 3
 
Sample Output
a:1
b:3
c:2
d:0
e:0
f:0
g:0
h:0
i:0
j:0
k:0
l:0
m:0
n:0
o:0
p:0
q:0
r:0
s:0
t:0
u:0
v:0
w:0
x:0
y:0
z:0
 
Author
linle
 
Source
 
Recommend
lcy | We have carefully selected several similar
problems for you: 1709 1710 1707 1701 1714
 
很简单的模拟题,注意给的第一个数是s0
 
题意:给两个字符串s0和s1,sn是sn-1和sn-2拼接而成的。问sn中每个字母出现的次数
 
附上代码:
 
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int f[][];
char s1[],s2[];
int i,j,T,n,m;
scanf("%d",&T);
while(T--)
{
scanf("%s %s %d",s1,s2,&n);
memset(f,,sizeof(f));
for(i=; s1[i]!='\0'; i++)
f[][s1[i]-'a']++; //字母转化为数字保存
for(i=; s2[i]!='\0'; i++)
f[][s2[i]-'a']++;
for(i=; i<=n; i++)
{
for(j=; j<; j++)
f[i][j]=f[i-][j]+f[i-][j]; //每一次都是前面两个相加
}
for(i=; i<; i++)
printf("%c:%d\n",i+'a',f[n][i]); //输出26个字母的个数
printf("\n");
}
return ;
}

hdu 1708 Fibonacci String的更多相关文章

  1. HDOJ(HDU) 1708 Fibonacci String

    Problem Description After little Jim learned Fibonacci Number in the class , he was very interest in ...

  2. HDU 1708 简单dp问题 Fibonacci String

    Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  3. Fibonacci String(hdu 1708)

    Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. HDU 3117 Fibonacci Numbers(围绕四个租赁斐波那契,通过计++乘坐高速动力矩阵)

    HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意:  求第n个斐波那契数的 ...

  5. HDU 4054 Number String

    HDU 4054 Number String 思路: 状态:dp[i][j]表示以j结尾i的排列 状态转移: 如果s[i - 1]是' I ',那么dp[i][j] = dp[i-1][j-1] + ...

  6. hdu 3117 Fibonacci Numbers 矩阵快速幂+公式

    斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...

  7. hdu 4786 Fibonacci Tree (2013ACMICPC 成都站 F)

    http://acm.hdu.edu.cn/showproblem.php?pid=4786 Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others) ...

  8. hdu 1021 Fibonacci Again(找规律)

    http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others ...

  9. HDU 4786 Fibonacci Tree(生成树,YY乱搞)

    http://acm.hdu.edu.cn/showproblem.php? pid=4786 Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others ...

随机推荐

  1. map.(parseInt)方法详解

    偶然间碰到这样一个问题: ["1","2", "3"].map(parseInt) //[ 1, NaN, NaN ] 运行结果 [ 1, ...

  2. (一)学习SpringBoot介绍

    为什么去要用到SpringBoot 特点: 创建独立的spring应用 嵌入tomcat ,jetty不需要部署 提供starters poms简化maven配置 尽可能自动配置spring'应用 提 ...

  3. ecshop二次开发之视频上传

    1.前台展示效果: 2.后台展示效果: 3.代码实现: 后台实现过程: 1.在languages/zh_cn/admin/goods.PHP中插入 $_LANG['tab_video'] = '视频上 ...

  4. python通过http(multipart/form-data)上传文件的方法

    之前写过一篇博客,说的如何python如何通过http下载文件,今天写一篇博客来介绍如下,python如何通过request库实现上传文件 这里主要是解决multipart/form-data这种格式 ...

  5. 【51nod1563】坐标轴上的最大团 贪心

    题面 坐标轴上有n个点,每个点有一个权值.第i个点的坐标是 xi ,权值是 wi .现在对这些点建图.对于点对 (i,j) ,如果 \(|xi−xj|≥wi+wj\) ,那么就给第i个点和第j个点之间 ...

  6. 为什么无法定义1px左右高度的容器

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...

  7. 软工作业———Alpha版本第二周小结

    姓名 学号 周前计划安排 每周实际工作记录 自我打分 zxl 061425 1.进行任务分配2.实现扫码和生成二维码功能 1.对主要任务进行了划分,但还为进行给模块间的联系2.完成了扫码签到功能 90 ...

  8. Directx11教程(55) 建立球形和锥形物体

    原文:Directx11教程(55) 建立球形和锥形物体 本教程中,我们新建2个model class,SphereModelClass以及CylinderModelClass,分别用来表示球形和锥形 ...

  9. 分布式Jmeter

    遇到的问题 1.压力不够大 2.单台瓶颈 3.网络瓶颈 分布式系统是由一组通过网络进行通信.为了完成共同的任务而协调工作的计算机节点组成的系统.分布式系统的出现是为了用廉价的.普通的机器完成单个计算机 ...

  10. POP介绍与使用实践(快速上手动画)

    http://adad184.com/2015/03/11/intro-to-pop/ 前言 动画在APP开发过程中 大家多多少少都会接触到 而且随着ios7的扁平化风格启用之后 越来越多的APP开始 ...