CODE AND SUM LOVE | Code vita 2018

Problem Description
```
Scanner sc = new Scanner(System.in);
long sum = 0;
int N = sc.nextInt();
for (int i = 0; i < N; i++) {
final long x = sc.nextLong(); // read input
String str = Long.toString((long) Math.pow(1 << 1, x));
str = str.length() > 2 ? str.substring(str.length() - 2) : str;
sum += Integer.parseInt(str);
}
System.out.println(sum%100);
```
Given N number of x’'s, perform logic equivalent of the above Java code and print the output

Constraints:

 1<=N<=10^7 0<=x<=10^18

Input Format:

 First line contains an integer N
Second line will contain N numbers delimited by space

Output Format:

 Number that is the output of the given code by taking inputs as specified above

Example 1

Input:

 4 8 6 7 4

Output:

 64

Example 2

Input:

3
1 2 3

Output:

14

CHAKRAVYUHA | Code vita 2017


During the battle of Mahabharat, when Arjuna was far away in the battlefield, Guru Drona made a Chakravyuha formation of the Kaurava army to capture Yudhisthir Maharaj. Abhimanyu, young son of Arjuna was the only one amongst the remaining Pandava army who knew how to crack the Chakravyuha. He took it upon himself to take the battle to the enemies.

Abhimanyu knew how to get power points when cracking the Chakravyuha. So great was his prowess that rest of the Pandava army could not keep pace with his advances. Worried at the rest of the army falling behind, Yudhisthir Maharaj needs your help to track of Abhimanyu's advances. Write a program that tracks how many power points Abhimanyu has collected and also uncover his trail.

 A Chakravyuha is a wheel-like formation. Pictorially it is depicted as below







A Chakravyuha has a very well-defined co-ordinate system. Each point on the co-ordinate system is manned by a certain unit of the army. The Commander-In-Chief is always located at the center of the army to better co-ordinate his forces. The only way to crack the Chakravyuha is to defeat the units in sequential order.

A Sequential order of units differs structurally based on the radius of the Chakra. The radius can be thought of as length or breadth of the matrix depicted above. The structure i.e. placement of units in sequential order is as shown below

1
2
3
4
5
16
17
18
19
6
15
24
25
20
7
14
23
22
21
8
13
12
11
10
9







          Fig 2. Army unit placements in Chakravyuha of size 5

The entry point of the Chakravyuha is always at the (0,0) co-ordinate of the matrix above. This is where the 1st army unit guards. From (0,0) i.e. 1st unit Abhimanyu has to march towards the center at (2,2) where the 25th i.e. the last of the enemy army unit guards. Remember that he has to proceed by destroying the units in sequential fashion. After destroying the first unit, Abhimanyu gets a power point. Thereafter, he gets one after destroying army units which are multiples of 11. You should also be a in a position to tell Yudhisthir Maharaj the location at which Abhimanyu collected his power points.

Input Format:

First line of input will be length as well as breadth of the army units, say N

Output Format:

Print NxN matrix depicting the placement of army units, with unit numbers delimited by (\t) Tab character
Print Total power points collected
Print coordinates of power points collected in sequential fashion (one per line)

Constraints:

1.     0 < N <=100

Sample Input and Output:

Input :
2

Output:

1 2
3 4

Total Power points : 1
(0,0)

Input:

 5

Output:

1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Total Power points : 3
(0,0)
(4,2)
(3,2)

MOUNTAIN PEAK SEQUENCE | Code vita 2017


Consider the first three natural numbers 1, 2, 3. These can be arranged in the following ways: 2, 3, 1 and 1, 3, 2. Inboth of these arrangements, the numbers increase to a certain point and then decrease. A sequence with this property is called a "mountain peak sequence".

Given an integer N, write a program to find the remainder of mountain peak arrangements that can be obtained by rearranging the numbers 1, 2, ...., N. When divided by Mod

Input Format:

One line containing the integer N

Output Format:

An integer m, giving the remainder of the number of mountain peak arrangements that could be obtained from 1, 2, ...., N is divide by Mod

Constraints:

Mod = 109+7
N ≤ 109

Example 1

Input:


3


Output:


2

Explanation:


There are two such arrangements: 1, 3, 2 and 2, 3, 1

Example 2

Input:


4

Output:


6

Explanation:


The six arrangements are (1, 2, 4, 3), (1,3,4,2), (1,4,3,2), (2,3,4,1), (2,4,3,1), (3,4,2,1)

FIBONACCI RIGHT ANGLED TRIANGLE | Code vita 2017

The Fibonacci series 1,1,2,3,5,8,... is well known. In this series, if Fn is the nth number
F1=1, F2=1, Fn=Fn-1+Fn-2
Every alternate number in the series stating with 5 (5,13,34,...) can be the hypotenuse of a right angled triangle. We call each of these a Fibonacci Right Angled Triangle, or FRAT for short. The larger of the remaining two sides is the nearest integer to (2/sqrt(5)) times the hypotenuse.
A factor of a positive integer is a positive integer with divides it completely without leaving a remainder. For example, for the number 12, there are 6 factors 1, 2, 3, 4, 6, 12. Every positive integer k has at least two factors, 1 and the number k itself.
The objective of the program is to find the number of factors of the even side of the smallest FRAT whose hypotenuse is odd and is larger than a given number
Input
The input is a positive integer N
Output
The number of factors of the even side of the smallest FRAT which has an odd hypotenuse greater than N

Constraints
The even side is less than 5000000
Example 1

Input:
10

Output:
6

Explanation:
The smallest FRAT that has an hypotenuse greater than 10 is (13,12,5). As the hypotenuse is odd, we take this. The even side is 12, factors are (1,2,3,4,6,12), a total of 6 factors. The output is 6
Example 2

Input:


20

Output:


10

Explanation:

The smallest FRAT that has an hypotenuse greater than 20 is (34,30,16). As the hypotenuse is even, we take the next FRAT, which is (89,80,39). The even side is 80, factors are (1,2,4,5,8,10,16,20,40,80), a total of 10 factors. The output is 10

CONCATENATING PRIME | Code vita 2017

If you like numbers, you may have been fascinated by prime numbers. Sometimes we obtain by concatenating two primes. For example, concatenating 2 and 3, we obtain the prime 23. The aim is to find all such distinct "concatenated primes" that could be obtained by concatenating primes ≤ a given integer N.
Input Format:
Integer N
Output Format:
M, the number of distinct primes that could be obtained by concatenating two primes ≤ N
Constraints:
N ≤ 70
Example 1
Input:
10
Output:
4
Explanations:
The primes ≤ 10 are 2, 3, 5, 7. These can be used to form the following concatenated numbers: 22, 23, 25, 27, 32, 33, 35, 37, 52, 53, 55, 57, 72, 73, 75, 77. Of these, there are four primes: 23 37 53 and 73. Hence the output is 4.

Example 2
Input:
20
Output:
17
Explanation:
The prime numbers up to 20 are 2 3 5 7 11 13 17 and 19.
Concatenating these two at a time in all possible ways, we get the following numbers:
22 23 25 27 211 213 217 219
32 33 35 37 311 313 317 319
52 53 55 57 511 513 517 519
72 73 75 77 711 713 717 719
112 113 115 117 1111 1113 1117 1119
132 133 135 137 1311 1313 1317 1319
172 173 175 177 1711 1713 1717 1719
192 193 195 197 1911 1913 1917 1919
We have the following 17 primes numbers in this list: 23 37 53 73 113 137 173 193 197 211 311 313 317 719 1117 1319 1913 Hence the output would be 17.

DISTRIBUTE BOOKS | Code vita 2019

Problem Description  For enhancing the book reading, school distributed story books to students as part of the Children’s day celebration...