Giter Site home page Giter Site logo

consecutive-zeroes's Introduction

Consecutive Zeroes Problem

Problem Statement:

Recently Manu visited the byteland. He was amazed with lots of different varieties of bytes he encountered there. Seeing this, he thought of a problem: Given an integer n, find out total possible bit string (either 0 or 1) of length n which don't have two contiguous zeroes in them. For example if n = 3, then total possible bit strings are 5 {010, 011, 101, 110, 111}. Now Manu started solving the problem but got busy with some important deployments. He asked you for the help. Please help him figure out the solution.

Input Format:

First line of test case contains an integer t denoting the number of test cases. In next t lines, each line contains an integer n, denoting the length of bit string.

Output Format:

For t test cases, output the total number of bit string possible. Since this number can be very large, output it modulo 10^9+7.

Constraints:

1 <= t <= 10^3
1 <= n <= 10^15

Input Example:

2
2
3

Output Example:

3
5

Explanation:

For first test case (n = 2), the total possible bit strings are {01,10,11}. So answer is 3. Second test case is same as provided in problem statement.

Subtask 1 (40 points):

t = 1
1 <= n <= 10^4

Subtask 2 (60 points):

original constraints

Execution of Codes

  1. Java Code

    javac ZeroBit.java 
    java ZeroBit
  2. Python Code

    python3 ZeroBit.py

consecutive-zeroes's People

Contributors

lalitmee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.