We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is the body of my main method, which passed all test cases.
Scanner sc = new Scanner(System.in);
int size = sc.nextInt();
long sum = 0;
while(sc.hasNextBigInteger()) {
BigInteger n = sc.nextBigInteger();
BigInteger b = BigInteger.valueOf(2).modPow(n, BigInteger.valueOf(1000000007));
long ans = b.intValue()*(sum+1)+sum;
sum = (long)ans%1000000007;
}
System.out.println((long)sum);
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Shashank and List
You are viewing a single comment's thread. Return to all comments →
This is the body of my main method, which passed all test cases.