题目大意:
  给定一个数k表示你可以从包括0的斐波那契数列中任取k个数,得到它们的和。求最小的不能得到的自然数。

思路:
  打表找规律,可以发现答案为f(2k+3)-1,然后用公式f(i)=f(i/2)*f((i+1)/2-1)+f(i/2+1)*f(x+1)/2)。当然也可以用矩阵快速幂。

 #include<cstdio>
#include<cctype>
#include<ext/hash_map>
inline int getint() {
char ch;
while(!isdigit(ch=getchar()));
int x=ch^'';
while(isdigit(ch=getchar())) x=(((x<<)+x)<<)+(ch^'');
return x;
}
const int mod=;
__gnu_cxx::hash_map<int,int> f;
int fib(const int x) {
if(!x) return ;
if(x==||x==) return ;
if(int t=f[x]) {
return t;
} else {
return f[x]=((long long)fib(x/)*fib((x+)/-)%mod+(long long)fib(x/+)*fib((x+)/)%mod)%mod;
}
}
int main() {
for(int T=getint();T;T--) {
printf("%d\n",(fib(+getint()*)+mod-)%mod);
}
return ;
}

[HDU6198]number number number的更多相关文章

  1. [ActionScript 3.0] 用TextField的方法getCharIndexAtPoint(x:Number, y:Number):int实现文字在固定范围内显示

    有时候我们遇到一行文字过多时必须固定文字的显示范围,但由于中英文所占字节数不一样,所以不能很好的用截取字符的方式去统一显示范围的大小,用TextField的getCharIndexAtPoint(x: ...

  2. 【leetcode】Single Number && Single Number II(ORZ 位运算)

    题目描述: Single Number Given an array of integers, every element appears twice except for one. Find tha ...

  3. 4.Single Number && Single Number (II)

    Single Number: 1. Given an array of integers, every element appears twice except for one. Find that ...

  4. leetCode191/201/202/136 -Number of 1 Bits/Bitwise AND of Numbers Range/Happy Number/Single Number

    一:Number of 1 Bits 题目: Write a function that takes an unsigned integer and returns the number of '1' ...

  5. [LeetCode#136, 137]Single Number, Single Number 2

    The question: Single Number Given an array of integers, every element appears twice except for one. ...

  6. [Locked] Strobogrammatic Number & Strobogrammatic Number II & Strobogrammatic Number III

    Strobogrammatic Number A strobogrammatic number is a number that looks the same when rotated 180 deg ...

  7. Single Number,Single Number II

    Single Number Total Accepted: 103745 Total Submissions: 218647 Difficulty: Medium Given an array of ...

  8. Ugly Number,Ugly Number II,Super Ugly Number

    一.Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are po ...

  9. Square Number & Cube Number

    Square Number: Description In mathematics, a square number is an integer that is the square of an in ...

  10. leetcode@ [136/137] Single Number & Single Number II

    https://leetcode.com/problems/single-number/ Given an array of integers, every element appears twice ...

随机推荐

  1. beego项目运行过程

    一:首先man.go,整个程序的入口 func main() { beego.Run() } 然后beego.run()代码 // Run beego application. // beego.Ru ...

  2. sicily 1500. Prime Gap

    Description The sequence of n ? 1 consecutive composite numbers (positive integers that are not prim ...

  3. django Rest Framework----认证/访问权限控制/访问频率限制 执行流程 Authentication/Permissions/Throttling 源码分析

    url: url(r'books/$',views.BookView.as_view({'get':'list','post':'create'})) 为例 当django启动的时候,会调用执行vie ...

  4. java基础52 编码与解码

    1.解码与编码的含义 编码:把看得懂的字符变成看不懂的码值,这个过程就叫编码    解码:根据码值查到相对应的字符,我们把这个过程就叫解码 注意:编码与解码时,我们一般使用统一的码表,否则非常容易出现 ...

  5. 洛谷P2194HXY烧情侣

    传送门啦 这个题可以说是tarjan强连通分量的裸题,但需要维护每个强连通分量的最小值,所以做法就很明确了. 我们先明确几个数组的意思: 1.首先是tarjan缩点中的几个数组: dfn[i]:i点的 ...

  6. 一步步教你编写不可维护的 PHP 代码

    译者注:这是一篇很棒文章,使用有趣的叙述方式,从反面讲解了作为一个优秀的 PHP 工程师,有哪些事情是你不能做的.请注意哦,此篇文章罗列的行为,都是你要尽量避免的. 随着失业率越来越高,很多人意识到保 ...

  7. hihoCoder #1190 : 连通性·四(点的双连通分量模板)

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho从约翰家回到学校时,网络所的老师又找到了小Hi和小Ho. 老师告诉小Hi和小Ho:之前的分组出了点问题,当服 ...

  8. sqlserver中的循环遍历(普通循环和游标循环)(转载)

    sql 经常用到循环,下面介绍一下普通循环和游标循环 1.首先需要一个测试表数据Student

  9. information_schema Introduction

    information_schema介绍 information_schema数据库是MySQL自带的,里面的“表”保存着服务器当前的实时信息.它提供了访问数据库元数据的方式.元数据是关于数据的数据, ...

  10. CVE-2012-1876Microsoft Internet Explorer Col元素远程代码执行漏洞分析

    Microsoft Internet Explorer是微软Windows操作系统中默认捆绑的WEB浏览器.         Microsoft Internet Explorer 6至9版本中存在漏 ...