0% found this document useful (0 votes)
373 views8 pages

Greetings From Globussoft: All The Best For Your Test Globussoft

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

Greetings From Globussoft

 Given below are 5 Programming questions, you have to solve


any 3 out of 5 questions.

 These 5 questions you can attempt in any technology like


C/C++, java, .Net

 To solve these 5 questions you’ve max. 3 hours.

 While solving these questions you are not allowed to use


any Search Engine like Google, Yahoo, Bing …

All the best for your test

Globussoft
Question: - 1

There are N cubes in a toy box which has 1-unit height, the width is double the height. The
teacher organizes a tower-building game. The tower is built by the cubes. The height of the
tower is H (h levels). The bottom of the tower contains M cubes; and for all above level, each
must contains a number of cubes which is exactly 1 less than or greater than the number of
cubes of the level right below it. Your task is to determine how many different towers can be
there. Two towers are considered different if there is at least one number i (1< i <=H) so that
the i'th level of one tower contains a different number of cubes to the i'th level of the other
tower.

Input

The first line of input file is the integer number t (0 < t < 1002), the number of test cases.
Each test case in one line, the line contains three positive number N, H and M (N <= 32767,
H<=60, M<=10).

Output

With each test case, write in one line, the total of different towers that can be founded.

Example:

Input
2
732
22 5 4

Output
2
10
(* In the first test case, all the towers are: 2-1-2, 2-3-2. *)

Question: - 2

A string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed


string t with length l>=1.
For example, the string “s = abaabaabaaba” is a (4,3)-repeat with t = aba as its seed string.
That is, the seed string t is 3 characters long, and the whole string s is obtained by repeating
t 4 times.

Write a program for the following task: Your program is given a long string u consisting
of characters ‘a’ and/or ‘b’ as input. Your program must find some (k,l)-repeat that occurs as
substring within u with k as large as possible.

For example, the input string “u = babbabaabaabaabab” contains the underlined (4,3)-
repeat s starting at position 5. Since u contains no other contiguous substring with more than
4 repeats, your program must output the maximum k.

Input

In the first line of the input contains H- the number of test cases (H <= 20). H test cases follow.
First line of each test cases is n - length of the input string (n <= 50000), the next n lines
contain the input string, one character (either ‘a’ or ‘b’) per line, in order.

Output

For each test cases, you should write exactly one interger k in a line - the repeat count that is
maximized.

Example:

Input
1
17
b
a
b
b
a
b
a
a
b
a
a
b
a
a
b
a
b

Output
4

Question: - 3

Professor Millman hates us, and worse, characterizes us as liars. We don’t care if he means it
or not, but we (more professional that him!) planned to give the lower and upper bound on
the number of liars in the class (so that you know what happens the next time he scolds us!).

To start with we took a survey of all students in the class. Each student gave a reply about
every student saying whether that student is a liar or not. These answers are in the form of
a Matrix A, where A[i][j] represents the reply given by the i-th student about the j-th student.
If that character is ‘L’ – it means he/she is a liar; if it’s ‘T’ – then it means that, that student is
a truth speaker.

We take the following as our definition of the terms Truth-Speaker, and Liar:
Truth-Speaker (‘T’): All his/her replies are true.
Liar (‘L’) : (S)he has made at least one false reply.

Input

T – the number of test cases; For each test case :


N – total number of students in the class
Matrix A of NxN characters, without space separation;

Output

For i-th test case output one line of the form “Class Room#i contains atleast A and atmost B
liars”, where A and B are the lower and the upper bounds on the number of liars respectively.
If there is a paradoxical class room, instead of the above line, print “Class Room#i is
paradoxical”.

Constraints:

T<=50; our class rooms contain at most 70 students.


Example:

Input
4
2
LL
TT
3
TTT
TTT
TTT
4
TLLL
LTLL
LLTL
LLLT
5
TLTLT
TTTTT
LLTLL
LLLLL
TLTLT

Output

Class Room#1 is paradoxical


Class Room#2 contains atleast 0 and atmost 3 liars
Class Room#3 contains atleast 3 and atmost 4 liars
Class Room#4 contains atleast 4 and atmost 4 liars

Question: - 4

Tree is an important data structure in Computer Science. Of all trees we work with, Binary
Tree is probably the most popular one. A Binary Tree is called a Strictly Binary Tree if every
nonleaf node in a binary tree has nonempty left and right subtrees. Let us define a Strictly
Binary Tree of depth d, as a Strictly Binary Tree that has at least one root to leaf path of
length d, and no root to leaf path in that tree is longer than d. So let us use a similar reasoning
to define a generalized structure.

An n-ary Tree is called a Strictly n-ary Tree if every nonleaf node in an n-ary tree has n
children each. AStrictly n-ary Tree of depth d can now be defined as a Strictly n-ary Tree that
has at least one root to leaf path of length d, and no root to leaf path in that tree is longer than
d.

Given the value of n and depth d, your task is to find the number of different strictly n-ary
trees of depth d.

The figure below shows the 3 different strictly binary trees of depth 2.

Input

Input consists of several test cases. Each test case consists of two integers n (0 < n <= 32), d
(0 <= d <= 16). Input is terminated a test case where n=0 and d=0, you must not process this
test case.

Output

For each test case, print three integers, n, d and the number of different strictly n-ary trees
of level d, in a single line. There will be a single space in between two integers of a line. You
can assume that you would not be asked about cases where you had to consider trees that
may have more than 210 nodes in a level of the tree. You may also find it useful to know that
the answer for each test case will always fit in a 200 digit integer.

Example:

Input

20
21
22
23
35
00
Output
201
211
223
2 3 21
3 5 58871587162270592645034001

Question: - 5
How far can you make a stack of cards overhang a table? If you have one card, you can create
a maximum overhang of half a card length. (We're assuming that the cards must be
perpendicular to the table.) With two cards you can make the top card overhang the bottom
one by half a card length, and the bottom one overhang the table by a third of a card length,
for a total maximum overhang of 1/2 + 1/3 = 5/6 card lengths. In general you can
make n cards overhang by 1/2 + 1/3 + 1/4 + ... + 1/(n + 1) card lengths, where the top card
overhangs the second by 1/2, the second overhangs tha third by 1/3, the third overhangs the
fourth by 1/4, etc., and the bottom card overhangs the table by 1/(n + 1).

This is illustrated in the figure below.

Input

The input consists of one or more test cases, followed by a line containing the number 0.00
that signals the end of the input. Each test case is a single line containing a positive floating-
point number c whose value is at least 0.01 and at most 5.20; c will contain exactly three
digits.

Output

For each test case, output the minimum number of cards necessary to achieve an overhang
of at least c card lengths.

Use the exact output format shown in the examples.


Example:

Input
1.00
3.71
0.04
5.19
0.00

Output
3 card(s)
61 card(s)
1 card(s)
273 card(s)

You might also like