Sunteți pe pagina 1din 40

PROJECT-1

Harry is a bright student. To prepare thoroughly for exams, he completes all the exercises
in his book! Now that the exams are approaching fast, he is doing book exercises day and
night. He writes down and keeps updating the remaining number of exercises on the back
cover of each book.

Harry has a lot of books messed on the floor. Therefore, he wants to pile up the books that
still have some remaining exercises into a single pile. He will grab the books one-by-one and
add the books that still have remaining exercises to the top of the pile.

Whenever he wants to do a book exercise, he will pick the book with the minimum number
of remaining exercises from the pile. In order to pick the book, he has to remove all the
books above it. Therefore, if there are more than one books with the minimum number of
remaining exercises, he will take the one which requires the least number of books to
remove. The removed books are returned to the messy floor. After he picks the book, he will
do all the remaining exercises and trash the book.

Since number of books is rather large, he needs your help to tell him the number of books
he must remove, for picking the book with the minimum number of exercises.

Note that more than one book can have the same name.

Input

The first line contains a single integer N denoting the number of actions. Then N lines
follow. Each line starts with an integer. If the integer is -1, that means Harry wants to do a
book exercise. Otherwise, the integer is number of the remaining exercises in the book he
grabs next. This is followed by a string denoting the name of the book.

Output

For each -1 in the input, output a single line containing the number of books Harry must
remove, followed by the name of the book that Harry must pick.

Constraints

1 < N 1,000,000
0 (the number of remaining exercises of each book) < 100,000
The name of each book consists of between 1 and 15 characters 'a' - 'z'.
Whenever he wants to do a book exercise, there is at least one book in the pile.

Example
Input:
6
9 english
6 mathematics
8 geography
-1
3 graphics
-1

Output:
1 mathematics
0 graphics
PROJECT-2

If there is a space to park the vechiles then some n number of vechiles are parked there and
then count how many are of cars, and how many of are scooters and note the arrival time
and the departure time, display the order of parked vechiles, and the color of vechile,if he
wants to take the vehicle from the parking he has to tell the number of vehicle if the
number is wrong he cant able to take the vehicle from parking in that case he has to tell
the car model and the color of vehicle and also the rc book of vehicle and also he has to
calculate the parking fees based on time he kept.

PROJECT-3

It is winter super sale and all the shops have various offers. Suraj selected N items to buy
and he is standing in the billing queue. It was then he noticed the offer "Buy two, get two".
That means for every two items you buy, they give you two items for free. However, items
can be of varying price, they always charge for 2 most costly items and give other 2 as free.
For example, if the items cost 1, 1, 2, 2, then you have to pay 4 and take all 4 items.

Suraj is busy reordering his items to reduce the total price he has to pay. He can separate
the items and get them on different bills if needed. Can you tell me what is the least price
Suraj has to pay to buy all the N items?

Input

The first line of the input contains an integer T denoting the number of test cases. The
description of T test cases follows. First line of each test case has single integer N. Second
line of each test case has N space separated integers, which are the costs of items Suraj
want to buy.

Output

For each test case, output a single line containing the required answer.

Constraints
1 T 1000

1 N 1000

1 Cost of items 1000

Example
Input:
3
4
1 1 2 2
2
10 200
7
1 1 10 2 2 2 1

Output:
4
210
14

Explanation

Example case 1

Suraj pays for 2 costly items and gets other 2 for free.

Example case 2

Suraj has to pay for both the items, he wont get anything for free.

Example case 3

Suraj separates the items into 2 bills. In one bill he pays 12. And in another bill he pays 2.

PROJECT-4

Santosh has a farm at Byteland. He has a very big family to look after. His life takes a
sudden turn and he runs into a financial crisis. After giving all the money he has in his
hand, he decides to sell some parts of his plots. The specialty of his plot is that it is
rectangular in nature. Santosh comes to know that he will get more money if he sells square
shaped plots. So keeping this in mind, he decides to divide his plot into minimum possible
square plots so that he can get maximum profit out of this.

So your task is to find the minimum number of square plots that can be formed out of the
rectangular plot.
Input

The input consists of T number of test cases. T lines follow. Each line consists of two
integers N and M which denotes the length and breadth of the rectangle.

Output

Output is a single line which denotes the minimum number of square plots that can be
formed

PROJECT-5

Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the
transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform
the withdrawal transaction (including bank charges). For each successful withdrawal the
bank charges 0.50 $US. Calculate Pooja's account balance after an attempted transaction.

Input

Positive integer 0 <X<= 2000 - the amount of cash which Pooja wishes to withdraw.

Nonnegative number 0<= Y<= 2000 with two digits of precision - Pooja's initial account
balance.

Output

Output the account balance after the attempted transaction, given as a number with two
digits of precision. If there is not enough money in the account to complete the transaction,
output the current bank balance.

PROJECT-6

Chef has bought N robots to transport cakes for a large community wedding. He has
assigned unique indices, from 1 to N, to each of them. How it will happen?

Chef arranges the N robots in a row, in the (increasing) order of their indices. Then, he
chooses the first M robots and moves them to the end of the queue. Now, Chef goes to the
robot at the first position in the row and hands it one cake. He then notes this robot's index
(say k) in his notebook, and goes to the k th position in the row. If the robot at this position
does not have a cake, he give him one cake, notes his index in his notebook, and continues
the same process. If a robot visited by Chef already has a cake with it, then he stops moving
and the cake assignment process is stopped.
Chef will be satisfied if all robots have a cake in the end. In order to prepare the kitchen
staff for Chef's wrath (or happiness :) ), you must find out if he will be satisfied or not? If
not, you have to find out how much robots have a cake, so that the kitchen staff can
prepare themselves accordingly.

Input

The first line of input contains a single integer T denoting the number of test cases.

The single line of each test case contains two space separated integers N and M.

Output

For each of the T test cases, output a single line:

If all N robots have a cake, output "Yes" (without quotes).

Otherwise, output "No" (without quotes) followed by a space and the number of robots
which have a cake.

PROJECT-7

Long ago there was a beautiful kingdom in the island of Sona, the golden island, deep
inside Africa. The trees in Sona Island are made of gold and farmers are the richest group
of people and are also heavy tax payers.

As you know that price of gold increases every year, the minister of Sona has proposed the
following tax policy.

Pay initTax units of gold in the first year.

In each of the next slot1 years, pay one unit of gold more than the previous year.

In each of the next slot2 years, pay double the units of gold of the previous year.

In each of the following years, pay number of gold units equal to the product of the
number of units paid in K recent years.

Given an integer N, find the number of units of gold to be paid in the Nth year. This result
can be huge, so output the result modulo 100000007 (108+7).

Input
First line has an integer T (number of test cases, 1 T 3). Each of the next T lines has 5
integers, initTax slot1 slot2 K N.
1 initTax, slot1, slot2 50
1 K slot1 + slot2 + 1
1 N 1000000000 (109)

Output

For each test case, output the tax in units of gold to be paid in the Nth year modulo
100000007 (108+7).

PROJECT-8

Anna Hazare is a well known social activist in India.

On 5th April, 2011 he started "Lokpal Bill movement".

Chef is very excited about this movement. He is thinking of contributing to it. He gathers
his cook-herd and starts thinking about how our community can contribute to this.

All of them are excited about this too, but no one could come up with any idea. Cooks were
slightly disappointed with this and went to consult their friends.

One of the geekiest friends gave them the idea of spreading knowledge through Face book.
But we do not want to spam people's wall. So our cook came up with the idea of dividing
Face book users into small friend groups and then identify the most popular friend in each
group and post on his / her wall. They started dividing users into groups of friends and
identifying the most popular amongst them.

The notoriety of a friend is defined as the averaged distance from all the other friends in his
/ her group. This measure considers the friend himself, and the trivial distance of '0' that he
/ she has with himself / herself.

The most popular friend in a group is the friend whose notoriety is least among all the
friends in the group.

Distance between X and Y is defined as follows:


Minimum number of profiles that X needs to visit for reaching Y's profile (Including Y's
profile). X can open only those profiles which are in the friend list of the current opened
profile. For Example:
- Suppose A is friend of B.
- B has two friends C and D.
- E is a friend of D.
Now, the distance between A and B is 1, A and C is 2, C and E is 3.

So, one of our smart cooks took the responsibility of identifying the most popular friend in
each group and others will go to persuade them for posting. This cheeky fellow knows that
he can release his burden by giving this task as a long contest problem.

Now, he is asking you to write a program to identify the most popular friend among all the
friends in each group. Also, our smart cook wants to know the average distance of everyone
from the most popular friend.

Input

Friends in a group are labelled with numbers to hide their Face book identity. The first line
of input contains the number of groups in which users are divided. First line of each group
contains the number of friends that belong to that group. i th line of each group contains the
space separated friend list of 'i'. You are assured that each friend's profile can be accessed
by the profile of every other friend by following some sequence of profile visits.

Output

Your output contains the most popular friend name label along with the average distance
(space separated) from all other friends (including himself / herself) in six digits of
precision. There might be multiple most popular friend, in that case output the friend
labelled with least number.

PROJECT-9
PROJECT-10

Pandigital products
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n
exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.

The product 7254 is unusual, as the identity, 39 186 = 7254, containing multiplicand,
multiplier, and product is 1 through 9 pandigital.

Find the sum of all products whose multiplicand/multiplier/product identity can be written
as a 1 through 9 pandigital.

HINT: Some products can be obtained in more than one way so be sure to only include it
once in your sum.
PROJECT-11

Stone Game

A game is played with three piles of stones and two players.


At her turn, a player removes one or more stones from the piles. However, if she takes
stones from more than one pile, she must remove the same number of stones from each of
the selected piles.

In other words, the player chooses some N>0 and removes:

N stones from any single pile; or

N stones from each of any two piles (2N total); or

N stones from each of the three piles (3N total).

The player taking the last stone(s) wins the game.

A winning configuration is one where the first player can force a win.
For example, (0,0,13), (0,11,11) and (5,5,5) are winning configurations because the first
player can immediately remove all stones.

A losing configuration is one where the second player can force a win, no matter what the
first player does.
For example, (0,1,2) and (1,3,3) are losing configurations: any legal move leaves a winning
configuration for the second player. Consider all losing configurations (xi,yi,zi) where xi yi
zi 100. We can verify that (xi+yi+zi) = 173895 for these.

Find (xi+yi+zi) where (xi,yi,zi) ranges over the losing configurations


with xi yi zi 1000.

PROJECT-12

Simple search engine using C


Project Introduction :
This is a SSE application. SSE stands for Simple Search Engine. It is a simple application that
can be used to search within text file on a system.

Project Specification:
Following is a summary of the requirements from the Requirements specification.

1. Keyword Search: Search for a given keyword and return the set of
documents containing the keyword. Rank the query results based on
how frequently the keyword has appeared in the documents.
2. Case-insensitivity: Keyword searches should be case insensitive.
3. Logical operators: Define logical operators AND and OR that can be
used to compose a complex query.
4. Phrase matching: Phrases that are enclosed in quotes should match
exactly.
5. Stemming: An asterisk (*) at the end of a keyword should match all
endings of the word.
6. The result of a query should be a set of path names ordered in
descending order of the number of occurrences of the keywords.
PROJECT-13

Sudoku is a logic-based, combinatorial number-placement puzzle. The objective is to fill a


99 grid so that each column, each row, and each of the nine 33 boxes (also called blocks
or regions) contains the digits from 1 to 9 only one time each. The puzzle setter provides a
partially completed grid." The rules for an N2 X N2sudoku are as follows :

The board is consists of N2 rows and N2 columns.

Numbers between 1 and N2(inclusive) are to be filled in each row such that :

All numbers in each row are distinct.

All numbers in each column are distinct.

All numbers in the sub-matrix having rows from (i*N + 1) to(i + 1)*N, and columns from
(j*N + 1) to (j + 1)*N both inclusive, should be distinct. 0 <= i,j<= N-1. Rows and columns
are 1 indexed. Each such sub-matrix is called a "box" or "region".

For this problem, you are required to solve a general N2X N2sudoku puzzle. Given a
partially filled Sudoku board, you have to fill it in as "perfect" a manner as possible.

PROJECT-14

Chef and Operators

Chef has just started Programming; he is in first year of Engineering. Chef is reading
about Relational Operators.

Relational Operators are operators which check relationship between two values. Given
two numerical values A and B you need to help chef in finding the relationship between
them that is,

First one is greater than second or,


First one is less than second or,
First and second one are equal.

Input

First line contains an integer T, which denotes the number of test cases. Each of the T lines
contains two integers A and B.

Output

For each line of input produce one line of output. This line contains any one of the
relational operators

'' , '' , '='.

Constraints

1 T 10000
1 A, B 1000000001

Example
Input:
3
10 20
20 10
10 10

Output:

PROJECT-15

Chef and Two Strings

Chef has found two very old sheets of paper, each of which originally contained a string of
lowercase Latin letters. The strings on both the sheets have equal lengths. However, since
the sheets are very old, some letters have become unreadable.

Chef would like to estimate the difference between these strings. Let's assume that the first
string is named S1, and the second S2. The unreadable symbols are specified with the
question mark symbol '?'. The difference between the strings equals to the number of
positions i, such that S1i is not equal to S2i, where S1i and S2i denote the symbol at the i the
position in S1 and S2, respectively.

Chef would like to know the minimal and the maximal difference between the two strings,
if he changes all unreadable symbols to lowercase Latin letters. Now that you're fully aware
of Chef's programming expertise, you might have guessed that he needs you help solving
this problem as well. Go on, help him!

Input

The first line of the input contains an integer T denoting the number of test cases. The
description of T test cases follows.

The first line of a test case contains a string S1.

The second line of a test case contains a string S2.

Both strings consist of lowercase Latin letters and question marks in places where the
symbols are unreadable.

Output

For each test case, output the minimal and the maximal difference between two given
strings separated with a single space.

Constraints

1 T 100

1 |S1|, |S2| 100

Subtask 1 (25 points): |S1| = 1

Subtask 2 (10 points): neither S1 nor S2 contains unreadable symbols

Subtask 3 (65 points): 1 |S1|, |S2| 100

Example
Input:
3
a?c
??b
???a
???a
?abac
aba?w

Output:
1 3
0 3
3 5

Explanation

Example case 1. You can change the question marks in the strings so that you obtain S1 =
abc and S2 = abb. Then S1 and S2 will differ in one position. On the other hand, you can
change the letters so that S1 = abc and S2 = bab. Then, the strings will differ in all three
positions.

Example case 2. Change the question marks this way: S1 = dcba, S2 = dcba, then the strings
will differ in 0 positions. You can also change the question marks so that S1 = aaaa, S2 =
dcba, then the strings will differ in 3 positions.

Example case 3. Change the question marks this way: S1 = aabac, S2 = abaaw, then the
strings will differ in 3 positions. Then, change the question marks this way: S1 = xabac, S2
= abayw, then they will differ in 5 positions.

PROJECT-16

The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-
chef all carry two-way transceivers so they can stay in constant contact. Of course, these
transceivers have a limited range so if two are too far apart, they cannot communicate
directly.

The Chef invested in top-of-the-line transceivers which have a few advanced features. One
is that even if two people cannot talk directly because they are out of range, if there is
another transceiver that is close enough to both, then the two transceivers can still
communicate with each other using the third transceiver as an intermediate device.

There has been a minor emergency in the Chef's restaurant and he needs to communicate
with both the head server and the sous-chef right away. Help the Chef determine if it is
possible for all three people to communicate with each other, even if two must communicate
through the third because they are too far apart.

Input

The first line contains a single positive integer T 100 indicating the number of test cases
to follow. The first line of each test case contains a positive integer R 1,000 indicating that
two transceivers can communicate directly without an intermediate transceiver if they are
at most R meters away from each other. The remaining three lines of the test case describe
the current locations of the Chef, the head server, and the sous-chef, respectively. Each such
line contains two integers X,Y (at most 10,000 in absolute value) indicating that the
respective person is located at position X,Y.

Output

For each test case you are to output a single line containing a single string. If it is possible
for all three to communicate then you should output "yes". Otherwise, you should output
"no".

To be clear, we say that two transceivers are close enough to communicate directly if the
length of the straight line connecting their X,Y coordinates is at most R.

Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1

Output:
yes
yes
no
PROJECT-17

Teddy and Tracy like to play a game based on strings. The game is as follows. Initially,
Tracy writes a long random string on a whiteboard. Then, each player starting with Teddy
makes turn alternately. Each turn, the player must erase a contiguous substring that exists
in the dictionary. The dictionary consists of N words.

Of course, the player that can't erase any substring in his turn loses the game, and the
other player is declared the winner.

Note that after a substring R is erased, the remaining substring becomes separated, i.e. they
cannot erase a word that occurs partially to the left of R and partially to the right of R.
Determine the winner of the game, assuming that both players play optimally.

Input

The first line contains a single integer T, the number of test cases. T test cases follow. The
first line of each test case contains a string S, the string Tracy writes on the whiteboard.
The next line contains a single integer N. N lines follow. The i-th line contains a single string
wi, the i-th word in the dictionary.

Output

For each test case, output a single line containing the name of the winner of the game.

Example
Input:
3
codechef
2
code
chef
foo
1
bar
mississippi
4
ssissi
mippi
mi
ppi

Output:
Tracy
Tracy
Teddy

Constraints

1 <= T <= 5

1 <= N <= 30

1 <= |S| <= 30

1 <= |wi| <= 30

S and wi contain only characters 'a'-'z'

PROJECT-18
You are given a 2D array with dimensions 6*6. An hourglass in an array is defined as a
portion shaped like this:

a b c
d
e f g
For example, if we create an hourglass using the number 1 within an array full of zeros, it
may look like this:

1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Actually, there are many hourglasses in the array above. The three leftmost hourglasses are
the following:

1 1 1 1 1 0 1 0 0
1 0 0
1 1 1 1 1 0 1 0 0
The sum of an hourglass is the sum of all the numbers within it. The sums for the
hourglasses above are 7, 4, and 2, respectively.

In this problem, you have to print the largest sum among all the hourglasses in the array.

Input Format

There will be exactly 6 lines of input, each containing 6 integers separated by spaces. Each
integer will be between -9 and 9, inclusively.

Output Format

Print the answer to this problem on a single line.

Sample Input

1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 2 4 4 0
0 0 0 2 0 0
0 0 1 2 4 0
Sample Output

19
Explanation

The hourglass possessing the largest sum is:

2 4 4
2
1 2 4
PROJECT-19

ATM APPLICATION

The following c console application is a simple concept of how ATM / ABM would function.
Basically, the console app manipulates data using sequential and random access files by
giving the users options to do so as if it's a real-time banking app.

Login (User Transactions) If selected, the user is asked for their account credentials
(this is analogous to swiping the card) a/c number and pin. Once entered and successfully
log-in the User Transactions menu is displayed.

Exit Ends the application.

Customer Log-in - If log-in with a customer a/c number then shown below
are your options.
Administrative log-in - If you are login with an admin a/c then shown
below are your options.
PROJECT-20

The Chef is having a dinner party and invited over all his friends. His guests being fairly
health conscious have exact protein requirements, and The Chef wishes to oblige them all.

The Chef will cook dishes for each individual guest using the ingredients in his kitchen.
Each ingredient has a specific amount of protein. The complete dish will have a protein
content value equal to the sum of the protein contents of the individual ingredients. To cook
a dish, The Chef can use any of the ingredients which appear on his shelf, but only in the
order which they appear on the shelf. The same ingredient may appear multiple times, and
can also be used as many times as it appears.

There are multiple ways to choose ingredients following the rules given above. However,
The Chef is only interested in choosing the set of ingredients that appear first in a
lexicographically ordered list of ingredients which satisfy the protein constraints. Your job
is to write a program that helps The Chef figure out which dish to serve!

Input

The first line of input contains t, the number of guests invited by The Chef (about 200).

Each test consists of three lines:

The first line consists of one integer 1 <= k <= 26 (the number of unique
ingredients on the shelf) and than k space-separated positive integers from the set
{1, 2, ... ,15} describing the protein content for each ingredient in an
alphabetically sorted list of unique ingredients. (the first protein value corresponds
with ingredient a, the second corresponds with the protein value for ingredient b,
and so on).

The second line contains L - a sequence of lower-case letters of the Latin alphabet
(at most 1000) which signify the name of the ingredient.

The third line contains one positive integer S which specifies the exact protein
requirement of this guest (1 < S < 500).

Output

For each test case either output the sequence of ingredients as described above, or the word
'IMPOSSIBLE' if no such subsequence exists.

Example
Input:
3
5 12 1 12 4 4
acccdadceb
2
3 5 4 6
abcbacbabcc
15
2 3 4
baba
7

Output:
IMPOSSIBLE
aaa
ab

Comments:

For the first guest we have five ingredients: a, b, c, d, e with protein values 12 1 12 4
4 respectively. To achieve a total protein value equal to 2 we need two ingredients b. But
there is only one, thus the answer is IMPOSSIBLE.

For the second guest we can achieve a total protein value of 15 with the ingredients taken
as: abc, bca, acb, cab, cba, bac, or aaa. Of these, the first according to lexicographic
order is aaa.

For the third guest, out of the two possibilities, ab is the correct answer.

PROJECT-21

There are N cities in Byteland numbered 1 to N with city 1 as the capital. The road network
of Byteland has a tree structure. All the roads are bi-directional. Alice and Bob are secret
agents working for the Bytelandian Security Agency (BSA). Each secret agent is assigned a
random city each month, where he/she must be stationed for the complete month. At the
end of each month, they come to the capital to submit their reports to the head of BSA.
They always take the shortest path from their city to the capital. If Alice is assigned city A
and Bob is assigned city B then they meet at a city C which is common to both their routes
to the capital and then travel together from C to the capital.

Alice and Bob wish to spend maximum time together in any trip. So for any pair of
assigned cities (A,B) they meet at a city C such that C is the farthest city from the capital
and appears in the shortest path from capital to A and capital to B. Since this happens each
month they compute this for each pair of assigned cities (A,B) and store it in a matrix M,
where M[A][B] = C, the city where they meet.

The importance of a city C(according to Alice and Bob), Im(C) is defined as the number of
times C appears in their matrix M. Alice and Bob are interested in finding the importance
of each city. Since this output can be large, output the sum S defined as S = (sum i=1 to N)
i*Im(i) modulo 1000000007.

Input

First line of input contains an integer t (t<=25), the number of test cases. Each test case
starts with an integer N (1<=N<=10000), the number of cities
The next N-1 lines contain two space separated integers u v (1<=u,v<=N) denoting a road
from u to v.

Output

For each test case output the required sum S

Example
Input:
3
5
1 2
1 3
2 4
2 5
3
1 2
1 3
1

Output:
41
12
1

Explanation
For the first test case, the matrix M is:
1 1 1 1 1
1 2 1 2 2
1 1 3 1 1
1 2 1 4 2
1 2 1 2 5

and the corresponding importance array is: 15 7 1 1 1


so the required sum is 1*15 + 2*7 + 3*1 + 4*1 + 5*1 = 41

For the second test case, the matrix M is:

1 1 1

1 2 1

1 1 3
and so the Importance array is: 7 1 1

So the required sum is 1*7 + 2*1 + 3*1 = 12

For the third test case, there is only one city, so the Matrix M just has one
entry 1, so S = 1

PROJECT-22

How many ways are there to place a black and a white knight on an N * M chessboard such
that they do not attack each other? The knights have to be placed on different squares. A
knight can move two squares horizontally and one square vertically, or two squares
vertically and one square horizontally. The knights attack each other if one can reach the
other in one move.

Input :

The first line contains the number of test cases T. Each of the next T lines contains two
integers N and M.

Output :

Output T lines, one for each test case, each containing the required answer for the
corresponding test case.

Sample Input:
3
2 2
2 3
4 5

Sample Output:
12
26
312

Constraints:
1 <= T <= 10000
1 <= N,M <= 100000
PROJECT-23

Chef's younger brother is in town. He's a big football fan and has a very important match
to watch tonight. But the Chef wants to watch the season finale of Master Chef which will
be aired at the same time. Now they don't want to fight over it like they used to when they
were little kids. They want to decide it in a fair way. So they agree to play a game to make a
decision. Their favourite childhood game!
The game consists of C boards. Each board i is a grid of dimension ni x mi.

Rules of the game:

- A coin is placed at (1,1) on every board initially.

- Each one takes a turn alternatively.

- In one turn, a player can choose any one board and move a coin from a cell (i,j) to one of
the following cells:

(i+1,j) OR (i+2,j) OR (i,j+1) OR (i,j+2) OR (i+1,j+1) OR (i+2,j+2).

- A coin cannot be moved out of the board at any point during the game.

- A coin cannot be moved once it reaches the cell (n,m) where n and m are the dimensions of
the board of that coin.

- A player MUST make one valid move.

- The player who makes the last move gets to watch TV.

Both of them are passionate about their interests and want to watch their respective shows.
So they will obviously make optimal moves in every turn. The Chef, being the elder
brother, takes the first turn.

Your task is to predict which show they will be watching tonight.

Input:

The first line of input contains a single integer T, the number of test cases. T tests follow.
Each test case starts with a single line containing C, the number of boards in the game.
Then follow C lines: each containing 2 integers ni and mi, the dimensions of the ith board.

Output:

Given the number and dimensions of boards, for each test case, output in a single line:
"Master Chef" if the Chef wins or "Football" if his brother wins.

Constraints:

1<=T<=10000

1<=C<=20

2<=ni,mi<=1000
Example:

Input:

22

Output:

MasterChef

Explanation:

The Chef can move the coin on the board from (1,1)->(2,2). This coin cannot be moved any
further. And so, the Chef wins.
Notice that if the Chef moves it to any other valid position, i.e. either to (1,2) or (2,1) he will
lose!

PROJECT-24

Everyone knows what a square looks like. Mathematically, a square is a regular


quadrilateral. This means that it has four equal sides and four equal angles (90 degree
angles). One beautiful day, Johnny eagerly examined the interesting properties of squares.
He did not forget you, his best friend and a talented programmer and thus made a problem
about squares to challenge your programming ability. The problem is: given a set of N
points in the plane, how many squares are there such that all their corners belong to this
set?

Now let's show Johnny your skill!

Input

The first line contains t, the number of test cases (about 10). Then t test cases follow.

Each test case has the following form:

The first line contains an integer N, the number of points in the given set (4 N
500).
Then N lines follow, each line contains two integers X, Y describing coordinates of a
point (-50 X, Y 50).

Output

For each test case, print in a single line the number of squares that have vertices belong to
the given set.

Example
Input:
1
7
0 0
0 1
1 0
1 1
1 2
2 1
2 2

Output:
3

Output details:
The three squares are:
(0 0), (0 1), (1 1), (1 0)
(1 1), (1 2), (2 2), (2 1)
(0 1), (1 0), (2 1), (1 2)
PROJECT-25

The Little Elephant from the Zoo of Lviv likes listening to music.

There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a
pair of integers Bi and Li - the band (represented as integer) that performed that song and
the length of that song in seconds. The Little Elephant is going to listen all the songs exactly
once in some order.

The sweetness of the song is equal to the product of the length of that song and the number
of different bands listened before (including the current playing song).

Help the Little Elephant to find the order that maximizes the total sweetness of all N songs.
Print that sweetness.

Input

The first line of the input contains single integer T, denoting the number of test cases. Then
T test cases follow. The first line of each test case contains single integer N, denoting the
number of the songs. The next N lines describe the songs in the MP3-player. The i-th line
contains two space-sparated integers Bi and Li.

Output

For each test, output the maximum total sweetness.

Constraints

1T5

1 N 100000 (105)

1 Bi, Li 1000000000 (109)

Example
Input:
2
3
1 2
2 2
3 2
3
2 3
1 2
2 4

Output:
12
16

Explanation

In the first sample: if he listens the songs in given order, then


B1=1, L1=2: the sweetness = 2 * 1 = 2
B2=2, L2=2: the sweetness = 2 * 2 = 4
B3=3, L3=2: the sweetness = 2 * 3 = 6
So the total sweetness is 12. In this case, you can check the total sweetness does not depend
on the order of the songs.

In the second sample: if he listens the songs in given order, then


B1=2, L1=3: the sweetness = 3 * 1 = 3
B2=1, L2=2: the sweetness = 2 * 2 = 4
B3=2, L3=4: the sweetness = 4 * 2 = 8
So the total sweetness is 15. However, he listens the song 2 firstly, then
B2=1, L2=2: the sweetness = 2 * 1 = 2
B1=2, L1=3: the sweetness = 3 * 2 = 6
B3=2, L3=4: the sweetness = 4 * 2 = 8
So the total sweetness is 16, and it is the maximum total sweetness.

PROJECT-26

Library management system (LMS)

Our KL University wants to provide a Library management system (LMS) interface to the
students and staff for the purpose of self issue and returns. If any user (student or staff)
wants to take book from library, he must interact with Library management system by
providing the credentials (username and password) of user. Then, LMS Allows the user to
get issues and returns by their own.
Add Book
details:
What details you want to Enter Book id
add: Enter Title
1. Book Enter author
2. User Enter no of
Add member:
3. Back to Main menu
Who are you? Enter student
1. Librarian id Enter Book ID:
2. User Enter
Please enter your
3. Exit username
credentials to
Select your Book issued to
verify:
option: student_id
Enter username
1. Issue Enter Book
Enter password
2. Return ID:
Wrong credentials, Please try once 3. Query Book returned by
again student_id
Enter Book Display
Select choice:
id: List
1. List of students to this book
issued Enter student
2. List of books issued to a id:
Our librarian maintains the details of books that are available in library, details
(credentials) of users that are already member of library. Here, we need two structures to
maintain these details. Library member structure contains student_id, username,
password. The Book structure contains Book_ID, Title, author, number of copies, Book
issued to (is a student_id who has taken copy of that book) .

The interface asks the user to enter his username and password. It verifies the
credentials of that particular user. If the entered credentials are correct, it will display two
options 1. Issues 2. Returns 3. Query. Otherwise, it will display a message wrong
credentials, Please try once again. User selects first option to get issue. The book will be
issued to that student by entering Book id. If selects second option, student can return the
book by entering book id. The option three provides a querying facility to enquire about
list of books issued to a particular student and a particular book issued a list of students.

PROJECT-27

Shopping cart application

A new shopping mall has been planned in Vijayawada. They want a software application to
maintain the product details, purchase maintenance and billing. Lets develop a better
application for this newly opened shopping mall.

Enter product details:


Select option
Product id
1. Add new product
Product name
2. Display all products
Quantity
3. Back
Price

Display products list


Display details of all products
Select option: Enter product is to purchase
Continue this process if user wants to purchase more products
1. Product management
2. Purchase product
3. Billing information
4. Exit

Display the details of all purchased products in ascending order of product IDs. And, total bill amount.

For this project, we need to create two structures Product, Bill. The Product structure
contains the members like product id, product name, quantity, price of each product. The
Bill structure has members like product id, product name, no of units purchased, price.

The main menu displays the list of options. The product management displays a sub
menu to add products that are maintained by Product structure. If user selects purchase
product option, it must ask the user Do you want to continue the purchase. If yes,
purchasing process will be continued. Otherwise, display main menu. For every purchase
of X units of product Y, X units will be deducted from available units of product Y. Finally,
display the details of all purchased products along with their total price.
PROJECT-28

EMPLOYEE MANAGEMENT SYSTEM

In this project, we maintain the details of all employees and their children using nesting of
structures. Consider each employee has four children and all are studying same number of
subjects in same class. These are the structure members of Employee, Children, and
Subjects.

Employee Children Subjects


ID name sub1
Name age sub2
Age gender sub3
Gender struct subjects total
Salary
Struct children

Here, You need to

1. List all employees whose children got 75% of total marks.

2. List children names of employees whose salary more than the average salary of all
employees

3. Count the number of male and female children of all employees.

4. Sort children of all employees by their names and print it.

PROJECT-29

HOTEL MANAGEMENT SYSTEM

Develop an application for hotel management system with the following modules using
structures, pointers to structure variables, passing structure pointers to function.

1. Get availability

2. Features of room

3. Room allocation
4. Show customer details

5. Room deallocation

6. Restaurant

7. Billing.

Make your own assumptions for this project, design and implement hotel management
system.

PROJECT-30

Project Description: By Using this Program User can able to do different following
operations using Arrays. 1. Insertion, 2. Deletion, 3. Sorting, 4. Searching, 5. Update, 6.
Retrieve, 7. Merging, 8. Append, 9. Exit. This Menu Driven Program will enhance the
array operations capability in c programming. In this program User can insert, delete, sort,
search, update, retrieve, merge, append the elements in array with respect to the user
choice.

PROJECT-31

TYPING TUTOR

Features:

This project provides certain name as user by default and there a facility to create a
new user too. You can enter your name as user.

In the project, you can view the total statistics.

The record option in the project is for displaying the data of user which has already
used the application. You can view typing speed, accuracy etc.

If you want to terminate the program without any use, you can select exit option in
the main menu.
PROJECT-32

Mini project Calendar Application is also a simple project made using C. It uses many
windows properties to make it colorful, for example, to indicate the vacation, it uses the red
foreground color. The calendar can be used for two purposes. First to see the date and
month as usual calendars and second to find out the day corresponding to given date. Some
of the silent features of the project are

It uses various windows properties to make the program colorful although it has
lack of graphics.
It entirely uses C codes, code is written in simple manner with lots of comments
Important notes can be added.
The date with such notes appears different than others with red background color.
The months can be navigated using arrow keys.

PROJECT-33

MODERN PERIODIC TABLE

This project will help you to understand file handling in C i.e. creating a file and accessing
the stored data in the file, modifying and removing the stored data. It will also help you to
understand the use of functions as well as different parameters of C programming
language.

The key features of Modern Periodic Table mini project in C are briefly described below:

Storage of Element Information: In the project, you can add any new element with its
name, symbol, atomic number, atomic weight and its some important properties. When
new element information is to be added to this Modern Periodic Table, you have to enter
1 in the main menu and input information in given format. This information is stored in
file created on the hard disk of computer by program itself.

Exploration of element Information: Another main function of this project is to explore


or to display the stored information. You can search an element by using any of the
following method:

1. By name of element

2. By symbol of element

3. By atomic number of element

4. By atomic weight of element


If you press 3 in the main menu, the program will be terminated.
PROJECT-34

CRICKET SCORE SHEET

First of all the project displays the welcome screen and the screen fades up to display the
main menu. The main menu comprises three options namely:

-> New Score Sheet

-> View Score Sheet

-> Exit

If 1 is entered, Cricket Score Sheet project asks for the name of new score sheet. When the
file is created, a message is displayed on the screen.

Then, the score sheet appears on screen in which the user has to input the following
information:

Competition

Venue

Match between and versus

Toss winner team

Elected choice of toss winner

Inning and date


Name of batsman and run hit by each of them

Name of bowler and run given by each blower

After inputting these data, the program asks user to input e to edit the data and c to
continue.

If the user inputs 2 in the main menu, the program asks for the name of file. If the file is
found, it is displayed. Otherwise, error message is printed on the screen.

The third option in main menu is exit. If 3 is entered in the main menu, the Cricket Score
Sheet project terminates.
PROJECT-35

The simple Project should accept the date month and year between 1900 to 2100 and
should display the calendar of that particular month displaying like below:

The project should be finished without using graphics. with logic you have to accomplish
the project

PROJECT-36

LOTTO GUESSER

Cobbletown has a lottery (a small version of California's Lotto) in which players


guess four number between 1 and 9. Larry likes to play and thinks he has a scheme to pick
winning numbers. He keeps a history of past winning numbers in a text data file. Larry
thinks that if a number hasn't occurred recently then it is more likely to show up as a
winner. (Obviously Larry isn't familiar with the statistical fact that each number has an
equal likelihood of being picked, since each week's drawing is an independent event). Larry
wants us to write a program to assist him in his wacky scheme.

INPUT REQUIREMENTS

The lotto history data: a file of unknown length, with four integers per line. Each integer
is in the range 1 to 9.

OUTPUT REQUIREMENTS
1. The four least frequently occurring integers in the history data. (That is, counting all
the weeks, the four numbers that appeared fewer times than any others).

2. The one integer with longest time since last occurrence. (That is, if you count
backward from now, the number for which you count the most weeks since it occurred).

FUNCTIONAL REQUIREMENTS

(You may assume that no data validity checking is required).

1. Determine and display the four integers which occur least often in the history data.
Note: To make the problem easier, if there is a tie between two or more numbers for
fourth place, it doesn't matter which one is printed.
2. Determine and display the integer which has gone the longest without appearing in a
winning sequence.

At a minimum your program must work correctly for the following sample data.

Test Data 1 2 3 4

5 6 7 8

8 7 6 5

1 5 6 7

4 3 2 1

PROJECT-37

The results from the mayor's race have been reported by each precinct as follows:

Candidate Candidate Candidate Candidate


Precinct A B C D
1 192 48 206 37
2 147 90 312 21
3 186 12 121 38
4 114 21 408 39
5 267 13 382 29

Write a program to do the following:

a. Read the raw vote totals from a data file that contains one row for each precinct.

b. Display the table with appropriate headings for the rows and columns.
c. Compute and display the total number of votes received by each candidate and the
percent of the total votes cast.

d. If any one candidate received over 50% of the votes, the program should print a message
declaring that candidate the winner.

e. If no candidate received 50% of the votes, the program should print a message declaring
a run-off between the two candidates receiving the highest number of votes; the two
candidates should be identified by their letter names.

f. For testing, run the program with the above data, and also with another data file where
Candidate C receives only 108 votes in precinct 4.

PROJECT-38

Accept any number of lines of input entered from standard input. A valid line contains a
word and a number. The word comes first, and is up to twenty alphabetic characters (A-Z)
in upper or lower case. The word may be preceded and followed by any number of blanks.
The number is a decimal integer greater than zero, and may be followed by any number of
blanks or a return. Input is terminated by EOF character. For each input word, print all
possible "subwords" that have as many characters as specified by the number. A
"subword" is a n-letter word comprised of only characters that are found in the given
word. If you are familiar with the game Scrabble, it's as though the input word is your pool
of letters, and you want to find all possible arrangements of n letters from your pool. .nf
For example, CAT 2 would produce CA CT AC AT TA TC and DOG 1 would produce D O
G and BIRD 3 would produce BIR BID IRD RID DIR RIB ... Note, that we are producing
combinations WITHOUT replacement, so in the BIRD 3 example, BBB and RRR are NOT
possible subwords. The output should echo the input line to standard output, followed by
the list of subwords, one word per line, left justified. Each set of output words should be
followed by one blank line. The program should respond to invalid input by echoing the
input line to the output, and then issuing a one line message indicating the nature of the
error:

"Illegal character in word"

"Illegal character in number"

"Number greater than length of word"

"Word longer than 20 characters"

After issuing the message, processing should resume with the next input line. When all
input has been processed, issue a message indicating the number of input words that were
processed (including word with errors) e.g., "End of input encountered, 4 words
processed."

PROJECT-39

CASTLES AND CREATURES

Write a program to play a simple "adventure"-style interactive game. The adventure


world consists of up to five castles each of which has up to seven rooms (35 total). Each
room has a treasure, worth a certain number of points, and a creature guarding the
treasure. The treasure can be captured by bluffing or fighting the creature. Bluffing
always has a 30% chance of succeeding. The odds for winning a fight vary from creature
to creature. The object of the game is to visit different rooms and gain as many treasure
points as possible. The player begins with 9 lives and each fight lost costs a life. (There's
no penalty for losing a bluff.) When all the lives (or all treasures) are gone the game ends.
The adventure world information (like castle and room names) is stored in a text
file/Structure. The program must read the text file/Structure and create a data structure
to represent the world. (HINT: Use a record structure for each room.) The program must
handle interaction with the player, including display of menus for castle and room choices,
display of current lives and treasure points accumulated, and responding to one-character
commands to fight, bluff, or move around the world.

PROJECT-40

One classic method for composing secret messages is called a square code. The spaces
are removed from the English text and the characters are written into a square (or
rectangle). For example, the sentence "If man was meant to stay on the ground god would
have given us roots" is 54 characters long, so it is written into a rectangle with 7 rows and 8
columns.
ifmanwas
meanttos
tayonthe
groundgo
dwouldha
vegivenu
sroots
The coded message is obtained by reading down the columns going left to right. For
example, the message above is coded as:

imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau

In your program, have the user enter a message in english with no spaces between the
words. Have the maximum message length be 81 characters. Display the encoded message.
(Watch out that no "garbage" characters are printed.) Here are some more examples:
Input Output
haveaniceday hae and via ecy
feedthedog fto ehg ee dd
chillout clu hlt io

S-ar putea să vă placă și