Challenge: Diwali Lights

Subdomeniu: Fundamentals (fundamentals)

Scor cont: 20.0 / 20

Submission status: Accepted

Submission score: 1.0

Submission ID: 464720723

Limbaj: java8

Link challenge: https://www.hackerrank.com/challenges/diwali-lights/problem

Cerinta

On the eve of [Diwali](https://en.wikipedia.org/wiki/Diwali), Hari is decorating his house with a serial light bulb set. The serial light bulb set has N bulbs placed sequentially on a string which is programmed to change patterns every second. If at least one bulb in the set is on at any given instant of time, how many different patterns of light can the serial light bulb set produce? 

Note: Lighting two bulbs \*-\* is different from \*\*- 

**Input Format**  
The first line contains the number of test cases T, T lines follow.   
Each line contains an integer N, the number of bulbs in the serial light bulb set. 

**Output Format**  
Print the total number of patterns modulo 10<sup>5</sup>

**Constraints**  
1 <= T <= 1000  
0< N < 10<sup>4</sup>

**Sample Input**

    2
    1
    2

**Sample Output**

    1
    3

**Explanation**

Case 1: 1 bulb can be lit in only 1 way.  
Case 2: 2 bulbs can be lit in -\*, \*-, \*\* i.e. 3 ways.

Cod sursa

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args)throws Exception  {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner inr = new Scanner (System.in);
		int t = inr.nextInt();
		BigInteger n[] = new BigInteger[t];
		BigInteger s[] = new BigInteger[t];
		BigInteger m = BigInteger.valueOf(100000);
		for(int i=0;i<t;i++){
			n[i] = inr.nextBigInteger();
		}
		for(int i=0;i<t;i++){
			s[i] = BigInteger.valueOf(2).modPow(n[i], m);
			s[i] = s[i].subtract(BigInteger.ONE);
			System.out.println(s[i]);
		}
	}

}
HackerRank Fundamentals – Diwali Lights