题目大意:
  给定一个数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. 查看GCC的内置宏定义

    开发过程中我们常常需要使用宏定义.. 为了尽可能多的使用GCC为我们提供的特性,首先我们需要知道gcc提供了那些特性... gcc -dM -E - < /dev/null 没错,就这么一句话就 ...

  2. 工具推荐:Backdoor-apk,安卓APK文件后门测试工具

    工具推荐:Backdoor-apk,安卓APK文件后门测试工具 Backdoor-apk可以看成是一个shell脚本程序,它简化了在Android APK文件中添加后门的过程.安全研究人员在使用该工具 ...

  3. Java IO,硬骨头也能变软

    开胃菜 先看一张网上流传的http://java.io包的类结构图: 当你看到这幅图的时候,我相信,你跟我一样内心是崩溃的. 有些人不怕枯燥,不怕寂寞,硬着头皮看源码,但是,能坚持下去全部看完的又有几 ...

  4. DirectFB简介以及移植[一]【转】

    转自:https://blog.csdn.net/wavemcu/article/details/39251805 ****************************************** ...

  5. ETL利器Kettle实战应用解析系列三

    本系列文章主要索引如下: 一.ETL利器Kettle实战应用解析系列一[Kettle使用介绍] 二.ETL利器Kettle实战应用解析系列二 [应用场景和实战DEMO下载] 三.ETL利器Kettle ...

  6. 使用UDP和TCP协议的各种应用和应用层协议

    IGMP和ICMP是传输层协议

  7. Access中替代case when的方法 .

    最近在做一个用Access的东东,其中用到了case when的方式,但是Access是不支持这种语法的,查询知道IIf和Swith可以作为替代,总结如下: IIf(expr, truepart, f ...

  8. 33 Introducing the Go Race Detector

    Introducing the Go Race Detector 26 June 2013 Introduction Race conditions are among the most insidi ...

  9. 07 go语言

    Home   Alexey Palazhchenko edited this page on 9 Jul · 89 revisions Welcome to the Go wiki, a collec ...

  10. Git系统学习网址

    https://code.csdn.net/help/CSDN_Code/progit/zh/07-customizing-git/01-chapter7