1sting 大数 递推
InputThe first line is a number n refers to the number of test cases. Then n lines follows, each line has a string made up of ‘1’ . The maximum length of the sequence is 200.
OutputThe output contain n lines, each line output the number of result you can get .
Sample Input
3
1
11
11111
Sample Output
1
2
8 如果最后一个数字和前一个合并。。f(n-2)
不合并 f(n-1)
fn = fn-2 + fn-1
大数!
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<fstream>
#include<set>
#include<memory>
#include<bitset>
#include<string>
#include<functional>
using namespace std;
typedef long long LL;
const int MAXN = 1e6 + ;
#define INF 0x3f3f3f3f
#define MAXN 203 int a[MAXN][MAXN];
char str[MAXN];
void add(int to[], int add[])
{
if (to[] < add[])
to[] = add[];
for (int i = ; i <= to[]; i++)
to[i] += add[i];
for (int i = ; i <= to[]; i++)
{
to[i + ] += to[i] / ;
to[i] %= ;
}
if (to[to[] + ] > )
to[]++;
}
void Init()
{
memset(a, , sizeof());
a[][] = , a[][] = ;
a[][] = , a[][] = ;
for (int i = ; i < MAXN; i++)
{
add(a[i], a[i - ]);
add(a[i], a[i - ]);
}
}
void print(int p)
{
for (int i = a[p][]; i > ; i--)
printf("%d", a[p][i]);
printf("\n");
}
int main()
{
int n, t;
scanf("%d", &n);
Init();
while (n--)
{
scanf("%s", &str);
t = strlen(str);
print(t);
}
}
1sting 大数 递推的更多相关文章
- HDU-1041-Computer Transformation,大数递推,水过~~
Computer Transformatio ...
- POJ 1737 Connected Graph (大数+递推)
题目链接: http://poj.org/problem?id=1737 题意: 求 \(n\) 个点的无向简单(无重边无自环)连通图的个数.\((n<=50)\) 题解: 这题你甚至能OEIS ...
- HDU 1865 1sting (递推、大数)
1sting Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- UVa 10328 Coin Toss(Java大数+递推)
https://vjudge.net/problem/UVA-10328 题意: 有H和T两个字符,现在要排成n位的字符串,求至少有k个字符连续的方案数. 思路:这道题目和ZOJ3747是差不多的,具 ...
- CodeVs 3150 (大数 + 递推)
#include<iostream> #include<cstdio> #include<cstring> #include<string> #incl ...
- hdu 1133 Buy the Ticket (大数+递推)
Buy the Ticket Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- 【hdoj_1865】1sting(递推+大数)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1865 本题的关键是找递推关系式,由题目,可知前几个序列的结果,序列长度为n=1,2,3,4,5的结果分别是 ...
- Tiling(递推+大数)
Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tili ...
- Children’s Queue HDU 1297 递推+大数
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1297 题目大意: 有n个同学, 站成一排, 要求 女生最少是两个站在一起, 问有多少种排列方式. 题 ...
随机推荐
- iOS Programming UINavigationController
iOS Programming UINavigationController the Settings application has multiple related screens of info ...
- InChatter系统之服务器开发(二)
现在我们继续进行InChatter系统的服务器端的开发,今天我们将实现服务契约同时完成宿主程序的开发,今天结束之后服务器端将可以正常运行起来. 系统的开发是随着博客一起的,颇有点现场直播的感觉,所有在 ...
- mysql中 for update 使用
解释: for update是在数据库中上锁用的,可以为数据库中的行上一个排它锁.当一个事务的操作未完成时候,其他事务可以读取但是不能写入或更新.例子: 比如一张表三个字段 , id(商品id), n ...
- opencv笔记
加载图像: OpenCV支持图像格式Windows位图(bmp),便携式图像格式(pbm,pgm,ppm)和Sun光栅(sr,ras). Mat image = imread( imageName, ...
- JavaSE-11 接口
学习要点 接口的定义 接口作为约定 接口作为能力 接口 为什么使用接口 需求描述 要求实现防盗门的功能(防盗门:带锁的门). 需求分析 门有“开”和“关”的功能,锁有“上锁”和“开锁”的功能. 将门和 ...
- Spring Data Redis入门示例:Hash操作(七)
将对象存为Redis中的hash类型,可以有两种方式,将每个对象实例作为一个hash进行存储,则实例的每个属性作为hash的field:同种类型的对象实例存储为一个hash,每个实例分配一个field ...
- vue 自定义指令使用
<template> <div> <!-- 让input元素在打开页面的时候就获得焦点 --> <input type="text" v- ...
- mybatis传多个参数(不使用@param注解情况下),3.4.2版本之后出现#{0}-#{n}参数绑定异常
解决方案: 在mybatis配置文件中声明setting属性的useActualParamName 参数值为false ** 这种方法解决mybatis3.4.2之后的版本产生该问题的解决方法**
- Layui下拉选渲染
下拉选渲染有很多方式,这个比较简单,记录一下: HTML代码如下: <div class="layui-input-inline"> <input type=&q ...
- U盘启动盘制作工具(安装Linux)
2018-09-15 17:36:42 1. Etcher 官网:https://etcher.io/ 资料来源:https://linuxmint-installation-guide.readt ...