题目链接:

Problem B

Time Limit: 2000/1000 MS (Java/Others)    

Memory Limit: 65536/65536 K (Java/Others)

Problem Description
 
  度熊面前有一个全是由1构成的字符串,被称为全1序列。你可以合并任意相邻的两个1,从而形成一个新的序列。对于给定的一个全1序列,请计算根据以上方法,可以构成多少种不同的序列。
 
Input
 
这里包括多组测试数据,每组测试数据包含一个正整数N,代表全1序列的长度。

1≤N≤200

 
Output
 
对于每组测试数据,输出一个整数,代表由题目中所给定的全1序列所能形成的新序列的数量。
 
Sample Input
1
3
5
 
Sample Output
1
3
8
 
题意:
 
思路:
 
可以发现是一个斐波那契数列,可以这样考虑,当多加一个1时,加的这个1可以和前边的合并,这时是dp[i-2]种方案,不和前边合并是dp[i-1]种方案,所以dp[i]=dp[i-1]+dp[i-2];
n太大,long long也不够用,所以就用数组模拟加法计算啦
 
AC代码:
 
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
const LL mod=1e9+;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int N=1e5+; int n;
LL dp[];
int str[][],dis[];
int fun()
{
mst(str,);
str[][]=;
str[][]=;
dis[]=;
dis[]=;
for(int i=;i<;i++)
{
for(int j=;j<=;j++)
{
str[i][j]+=str[i-][j]+str[i-][j];
// str[i][j+1]+=(str[i-1][j]+str[i-2][j])/10;
}
for(int j=;j<=;j++)
{
str[i][j+]+=str[i][j]/;
str[i][j]%=;
}
}
}
int main()
{
fun();
while(scanf("%d",&n)!=EOF)
{
for(int i=;i>=;i--)
{
if(str[n][i]!=)
{
for(int j=i;j>=;j--)printf("%d",str[n][j]);
break;
}
}
printf("\n");
} return ;
}

hdu-5686 Problem B(斐波那契数列)的更多相关文章

  1. HDOJ/HDU 5686 Problem B(斐波拉契+大数~)

    Problem Description 度熊面前有一个全是由1构成的字符串,被称为全1序列.你可以合并任意相邻的两个1,从而形成一个新的序列.对于给定的一个全1序列,请计算根据以上方法,可以构成多少种 ...

  2. hdu number number number 斐波那契数列 思维

    http://acm.hdu.edu.cn/showproblem.php?pid=6198 F0=0,F1=1的斐波那契数列. 给定K,问最小的不能被k个数组合而成的数是什么. 赛后才突然醒悟,只要 ...

  3. HDU 1715 (大数相加,斐波拉契数列)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1715 大菲波数 Time Limit: 1000/1000 MS (Java/Others)     ...

  4. hdu 2044:一只小蜜蜂...(水题,斐波那契数列)

    一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...

  5. [HDU 4549] M斐波那契数列

    M斐波那契数列 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Sub ...

  6. HDU 1316 (斐波那契数列,大数相加,大数比较大小)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1316 Recall the definition of the Fibonacci numbers: ...

  7. hdu 4549 M斐波那契数列 矩阵快速幂+欧拉定理

    M斐波那契数列 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Problem ...

  8. hdu 5914(斐波拉契数列)

    Triangle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Su ...

  9. SPOJ 5152 Brute-force Algorithm EXTREME && HDU 3221 Brute-force Algorithm 快速幂,快速求斐波那契数列,欧拉函数,同余 难度:1

    5152. Brute-force Algorithm EXTREME Problem code: BFALG Please click here to download a PDF version ...

随机推荐

  1. OC:内存管理、dealloc方法、copy知识点

    属性的声明:使⽤@property声明属性
 例如:@property NSString *name: 相当于@interface中声明了两个⽅法(setter.getter): 属性的实现:使⽤@s ...

  2. C++开发必看 四种强制类型转换的总结 [转]

    一.C风格的强制类型转换(Type Cast)很简单,不管什么类型的转换统统是:     TYPE b = (TYPE)a 二.C++风格的类型转换提供了4种类型转换操作符来应对不同场合的应用. co ...

  3. cocos2d-x 如何保持屏幕常亮

    转自:http://blog.csdn.net/wolfking_2009/article/details/8939027 貌似cocos2d-x没有接口直接做这个功能 而各个平台又不一样,所以只能对 ...

  4. PostgreSQL没有redo log multiplexing

    与Oracle不同的是,PostgreSQL中压根没有这种的东西. 若以,如果因为写在线WAL文件是发生磁盘I/O错误,那么数据库系统就启动不了了. 解决的办法,我想,在PostgreSQL中,如论如 ...

  5. [转]AsyncDisplayKit 教程:达到 60 FPS 的滚动帧率

    [原文:https://github.com/nixzhu/dev-blog/blob/master/2014-11-22-asyncdisplaykit-tutorial-achieving-60- ...

  6. 【M33】将非尾端类设计为抽象类

    1.考虑下面的需求,软件处理动物,Cat与Dog需要特殊处理,因此,设计Cat和Dog继承Animal.Animal有copy赋值(不是虚方法),Cat和Dog也有copy赋值.考虑下面的情况: Ca ...

  7. EntityFramework Code First 优化-IIS 8的第一次优化请求配置

    首先需要在Window中添加Application Initialization Application Initialization 在IIS中配置Application Pool 编辑Applic ...

  8. HDU 5578 Friendship of Frog 水题

    Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  9. Effective C++笔记04:设计与声明

    条款18:让接口easy被正确使用,不易被误用 1,好的接口非常easy被正确使用,不easy被误用.你应该在你的全部接口中努力达成这些性质. 2,"促进正使用"的办法包含接口的一 ...

  10. input text框和 checkbox 连带被选中的情况

    <html> <head></head> <body> <ul> <li><input type="checkb ...