Feeds:
Posts
Comments

Archive for the ‘Easy Problems’ Category

Problem no. 12

/*
Problem no. : 12
Submitted by :  Rafiul Sabbir
Dept. : CSE
Institution : United International University
Submitted at : 01/11/09
*/

Standardized exams often consist of many multiple choice questions.  One type of multiple choice question gives two expressions and asks if the value of the expression on the left is greater than, less than, or equal to the value of the expression on the right.  The answer A indicates that the value of the left expression is greater than the value of the right one, the answer B indicates that the value of the left expression is less than the value of the right one, and the answer C indicates that the two expressions are equal.  Your task is to write a program that will list the correct answers for such a set of multiple choice questions.

Input:

The first line of the input is an integer n that represents the number of data collections that follow where each collection is on a single line.  Each data collection represents a multiple choice question and contains three integers x, y, and z with a single space between each pair of integers.  The left expression in a question is evaluated as x + y.  The right expression in a question is given directly by the value z.

Output:

Your program should produce n lines of output (one for each data collection).  Every line of output should contain an uppercase letter representing the correct answer of the corresponding multiple choice question.  If the sum of x and y exceeds z, the answer should be A.  If the sum of x and y is less than z, the answer should be B.  Finally, if the sum of x and y equals z, the answer should be C.

The output is to be formatted exactly like that for the sample output given below.

Assumptions:

The value of n will be between 1 and 100, inclusive.

Each input integer will be between -1,000,000 and 1,000,000, inclusive.

Sample Input:

3

2 99 101

25 5 29

-10 7 0

Sample Output:

C

A

B

Read Full Post »

Problem no. 11

/*
Problem no. : 11
Submitted by :  Rafiul Sabbir
Dept. : CSE
Institution : United International University
Submitted at : 31/10/09
*/

General Statement:

When processing arrays, many languages (such as Java) require a user to declare the array’s size representing the number of elements that it can hold.  If an array is declared with a size of k, then it can hold k elements.  Typically, the legal range of indices for an array starts with zero and ends with k-1.  Thus, if an array is declared with a size of 10, the legal indices for it range from 0 to 9.

Your task is to write a program that determines if an input index value is legal for a given array size.

Input:

The first line of the input contains an integer n that represents the number of data collections that follow where each data collection is on a single line.  Each input line contains two integers k and x separated by a single space.  The first integer, k, represents the declared size of an array.  The second integer represents an index for that array.

Output:

Your program should produce n lines of output (one for each data collection).  The output for each data collection should indicate if the given index, x, is legal for the declared array size (falls within the range between 0 and k-1, inclusive.).    If it is legal, your program should output the word legal.  If it is not legal, your program should output the phrase out of bounds.

The output is to be formatted exactly like that for the sample output given below.

Assumptions:

The value of n will be between 1 and 100, inclusive.

The value of each k will be between 1 and 1,000,000, inclusive.

The value of each x will be between -1,000,000 and 1,000,000, inclusive.

Sample Input:

4

10 9

10 10

5 -1

5 0

Sample Output:

legal

out of bounds

out of bounds

legal

Read Full Post »

Problem no. 10

/*
Problem no. : 10
Submitted by :  Rafiul Sabbir
Dept. : CSE
Institution : United International University
Submitted at : 31/10/09
*/

General Statement: Your friends are trying to complete a crossword puzzle and need a three letter word with the second letter being A.  They repeatedly suggest words to each other hoping that they fit.  Someone suggests to write a program that can quickly identify if a given word fits the above description.  Your task is to write that program.

Input:  The first line of the input contains an integer n that represents the number of data collections that follow where each data collection is on a single line.  Each input line contains a string representing a word suggested by your friends.  The string will contain only uppercase letters.

Output: Your program should produce n lines of output (one for each data collection).  Each line should contain text indicating if the input word fits the clue.  If the word has three letters, and the second letter is A, then your program should output FITS.  Otherwise, your program should output DOES NOT FIT.

The output is to be formatted exactly like that for the sample output given below.

Sample Input:

3

CAT

FATE

TEN

Sample Output:

FITS

DOES NOT FIT

DOES NOT FIT

Read Full Post »

Problem no. 09

/*
Problem no. : 09
Submitted by :  Gultu
Dept. : CTE
Institution : United International University
Submitted at : 30/10/09
*/

General Statement: A town in Death Valley has a water tank that contains 10,000 gallons of water. If there is no rain, calculate the number of weeks the water will last for an input weekly water usage.

Input: The data set is on a single line. There are an unknown number of integers in the data set. The integer 0 is used to indicate the end of the data.

Output: Use all upper case letters. The output is to be formatted exactly like that for the sample output given below.

Assumptions: The weekly usage does not exceed 10,000 gallons. The 0 used to indicate the end of the data is not part of the data for the problem.

Discussion: Do not include the last week if the water remaining for that week is less than the weekly usage amount.

Sample Input: 1750 1000 4325 0

Sample Output:
1750 GALLONS PER WEEK WILL LAST 5 WEEKS
1000 GALLONS PER WEEK WILL LAST 10 WEEKS
4325 GALLONS PER WEEK WILL LAST 2 WEEKS

Read Full Post »

Problem no. 08

/*
Problem no. : 08
Submitted by :  Rafiul Sabbir
Dept. : CSE
Institution : United International University
Submitted at : 30/10/09
*/

General Statement: Read the amount of money you have and the prices of the items you intend to buy. Determine whether you have enough money to buy everything you selected or whether you are short of money. If you do not have enough money, indicate the amount of the shortfall. Be sure to include 8% tax when figuring the amount you need.

Input: The first line in the data set is an integer that represents the number of data collections that follow. The 1st number of each test cases is the total amount of money you have.After that there are an unknown number of money amounts in each data set. The value –1 is used to indicate the end of the collection of prices.

Output: All letters are to be upper case. Include the amount of shortfall if you do not have enough money. This money amount is to have a dollar sign ($) in front of the amount and it is to be rounded to 2 decimal places. The output is to be formatted exactly like that for the sample output given below.

Assumptions: The –1 used to indicate the end of a data collection is not part of the data for the problem.

Sample Input:
3
10.50 7.60 1.26 3.49 -1
15.75 6.00 3.98 -1
21.00 5.25 5.75 4.76 3.98 1.50 -1

Sample Output:
$2.84 SHORT
ENOUGH MONEY
$1.94 SHORT

Read Full Post »

Problem no. 07

/*
Problem no. : 07
Submitted by :  Rafiul Sabbir
Dept. : CSE
Institution : United International University
Submitted at : 30/10/09
*/

The Indianapolis 500 race is just a few weeks away. They need your help in creating a program that will provide the order in which the cars are to appear at the starting line (ordering is according to the number placed on the car).

There are two garages where the race cars are stored. Each garage will form a line of 5 cars that are sorted by the number on the car. As the cars from the two garages merge to form a single start line, your program must maintain the ordering such that the smallest numbered cars are earlier in the line than those with larger numbers.

Note: Some cars may share the same number, and the numbers range from 1 to 10. You may assume that there are always 5 cars in each garage prior to the merging and each garage is already sorted.

Example 1:
Enter the order for garage 1: 1 1 2 3 4
Enter the order for garage 2: 2 2 3 4 5

The final merged order is:

1 1 2 2 2 3 3 4 4 5

Example 2:
Enter the order for garage 1: 1 2 3 4 5
Enter the order for garage 2: 5 6 7 8 9

The final merged order is:

1 2 3 4 5 5 6 7 8 9

Read Full Post »

Problem no. 06

/*
Problem no. : 06
Submitted by :  Rafiul Sabbir
Dept. : CSE
Institution : United International University
Submitted at : 28/10/09
*/

Sherlok Homes is in a great problem.Though he is a very famous detective but he is not that much good in math.Once he was given some numbers & was said to find out a specific number from the given numbers but the old man was unable to do so.He knew you as a very good programmer & earnestly requested you to make a program to find out a number from some given numbers.Now your job is very simple,to write a code that can find a number from some given numbers.

Your input will be of three lines.First line will take the number “n” which is the number of numbers you will take first.Then in the second line you will take n numbers & then you will take another number “p” in another line.Your job is to find that whether the number “p” is within the n numbers or not.

Sample Input
9
12 45 78 89 56 86 49 16 43
78
5
13 46 79 86 53
19

Sample output
78 is present within this 9 numbers
19 is not present within this 5 numbers

Read Full Post »

Problem no. 05

/*
Problem no. : 05
Submitted by :  Sheikh Faiyaz Moorsalin
Dept. : CSE
Institution : United International University
Submitted at : 19/09/09
*/

Given a string you have to find out how many vowel,consonant,white space,special character(i.e. ‘!’ ‘,’ ‘.’ ‘?’ ‘!’ ) exist within the string.
N.B. : Test case has no limits.string size is at most 100,both upper and lower case will be there within the input string.

Sample Input
I am a boy!
peter parker picks purple flower.
Hi! are you from united international University?

Sample output

Case 1: vowel-4;Consonant-3;white space-3;special character-1
Case 2: vowel-9;Consonant-19;white space-4;special character-1
Case 3: vowel-19;Consonant-22;white space-6;special character-2

Read Full Post »

Problem no. 04

/*

Problem no. : 04

Submitted by :  Gultu

Dept. : CTE

Institution : United International University

Submitted at : 18/09/09

*/

Now we will try to reverse a number.Our job is very simple,just to input a number & then write it reversibly.

Input

You will give a number.The number will be 0<number<10000.There is no bound of test cases.Input will be terminated for the  number  0.

Output

For each line of input output will be the reverse of the input in a new line.

Sample Input

93824

9436

639

0

Sample Output

42839

6349

936

Read Full Post »

Problem no. 03

/*

Problem no. : 03

Submitted by :  Rafiul Sabbir

Dept. : CSE

Institution : United International University

Submitted at : 18/09/09

*/

Samir is in a big problem.His math teacher gave him some home works where he needs to find out the numbers divisible by a definite number within a given range but as he doesn’t know programming he is in deep trouble that all his job is to be done by him manually which is very much time killing.Here our job is to write a program that will help Samir to find out all the numbers divisible by a definite number within a given limit.

You will give the starting point & the end point & the divider & the program will output  all the numbers divisible by the given divider within the starting & the end point.

Input

There should be three integers for each line of input which will be the “starting point”,”end point” & the “divider” respectively.The divisor must be greater than 0.Input will be terminated by “End of File”.

Output

For each line of input there should be a line of output which will show all the numbers divisible by the given divider within the start & the end point.

Sample Input

12 45 7

104 365 19

5 200 25


Sample Output

14 21 28 35 42

114 133 152 171 190 209 228 247 266 285 304 323 342 361

25 50 75 100 125 150 175 200

Read Full Post »

Older Posts »