Untitled 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

PRIME NUMBERS

2. Print the You are given an integer N. You need to print the series of all prime
numbers till N.

Input Format

The first and only line of the input contains a single integer N denoting the number
till where you need to find the series of prime number.

Output Format

desired output in single line separated by spaces.

Constraints

1<=N<=1000

SAMPLE INPUT:

SAMPLE OUTPUT

2357

BOOK CRICKET

12.The rules of a cricket game are as follows:

 The game is played for N overs.


 Each over consists of 6 balls.
 The batting team has P number of players.
 At the start of the game, the first 2 players come out to play. The first player is
called the striker (the one facing the current ball) and the second player is
called the non-striker.
 The striker continues being the striker until he either gets OUT (he will be
replaced by the next player who is yet to play) or his strike
gets ROTATED (the striker becomes the non-striker and the non-striker
becomes the striker).
 Each ball consists of one of the following events:
 0 : This adds no score to the striker.
 1 : Adds one run to the striker and the strike gets ROTATED.
 2 : Adds two runs to the striker.
 4 : Adds four runs to the striker.
 6 : Adds six runs to the striker.
 W : The striker is OUT and will be replaced by next player.
 At the end of every over, the strike will be ROTATED again.

Write a program to implement the scoreboard of a cricket game.

Input format

 First line: T (number of test cases)


 First line in each test case: Two space-separated integers N and P
 Second line in each test case: Details of N overs (As a string)

Output format

For each test case, print the first line as "Case X:" (where X refers to the test case
number). In the next P lines, print "Player Y: " followed by the score of
the Yth player.

Note:

If the player is currently not out, output a "∗" after the score.
If the player has not yet come out to play, output "DNB" (Did not bat) instead of the
score.
It is guaranteed that at the end of the match at least 2 players are still not out.
It is guaranteed that the last ball of the match is not a "W".

Constraints

1≤T≤10
2≤P≤10
1≤N≤10000
SAMPLE INPUT

2
12
400111
24
4444W4666666

SAMPLE OUTPUT

Case 1:
Player 1: 6*
Player 2: 1*
Case 2:
Player 1: 16
Player 2: 36*
Player 3: 4*
Player 4: DNB

6(M). Akshara is a Maths teacher at Dynamic Public School.One day she decided to take an unusual
test of all her students.She took all her students to a fair.There she took them to a candy room.The
room had 2 doors and behind each door was unlimited supply of candies.The excitement of the
students could not be measured.Each student wanted a specific amount of candies.Now here was the
test.

At a time 1 student could enter 1 door.After he exits another will enter.No time is lost when there is
change of students.For proccessing 1 candy it took 1 second.The teacher gave exactly X amount of
time for all the students to get their specific amount of candies.So the students ask you for help in
determining whether it is possible for all the students to get their candies or not in X amount of time.

Input:

The first line contains T denoting the number of test cases.Each testcase consist of two lines containing
n and x denoting the number of students and the time given by the teacher.The next line contains n
space separated numbers denoting the amount of candy each student wants.

Output:

For each testcase print YES if it is possible or NO.

Constraints:

1<=T<=25
1<=N<=100

1<=x<=100000

0<=A[i]<=100

SAMPLE INPUT

2
3 4
2 4 2
3 3
3 3 3

SAMPLE OUTPUT

YES
NO
1(E).Patlu and Motu works in a building construction, they have to put some number of bricks Nfrom
one place to another, and started doing their work. They decided , they end up with a fun challenge who
will put the last brick.

They to follow a simple rule, In the i'th round, Patlu puts i bricks whereas Motu puts ix2 bricks.

There are only N bricks, you need to help find the challenge result to find who put the last brick.

Input:

First line contains an integer N.

Output:

Output "Patlu" (without the quotes) if Patlu puts the last bricks ,"Motu"(without the quotes) otherwise.

Constraints:

1 ≤ N ≤ 10000

SAMPLE INPUT

13
SAMPLE OUTPUT

Motu

Given a number N. our task is to find the closest Palindrome number


whose absolute difference with given number is minimum.
Input:
The first line of the input contains integer T denoting the number of test
cases. Each test case contains a number N.
Output:
For each test case, the print the closest palindrome number.
Note: If the difference of two closest palindromes numbers is equal
then we print smaller number as output.
Constraints:
1<=T<=1000
1<=n<=10^14
Input :
2
9
489
output:
9
484
MEDIUM
A number is known as special bit number if its binary representation contains atleast two consecutive
1's or set bits. For example 7 with binary representation 111 is a special bit number. Similarly 3 (11) is
also a special bit number as it contains atleast two consecutive set bits or ones.

Now the problem is, You are given an Array of N integers and Q queries. Each query is defined by two
integers L, R. You have to output the count of special bit numbers in the range L to R.

Input

Contains integer N, no of Array elements and Q - Total Number of Queries.

Next line contains N integers A[i] defining Array elements.

Next Q lines contains Queries of the type 1≤L≤R≤N

Output

Output Q lines containing answer for the ith Query.

Constraints

0≤A[i]≤109

1≤N≤105

1≤Q≤105

SAMPLE INPUT

5 3
3 5 1 12 7
1 3
2 3
1 5
SAMPLE OUTPUT

1
0
3

3.Given an array A of N integers, classify it as being Good Bad or Average. It


is called Good, if it contains exactly X distinct integers, Bad if it contains
less than X distinct integers and Average if it contains more than X distinct
integers.
Input format:

First line consists of a single integer T denoting the number of test cases.

First line of each test case consists of two space separated integers denoting N
and X.

Second line of each test case consists of N space separated integers denoting
the array elements.

Output format:

Print the required answer for each test case on a new line.

SAMPLE INPUT

4 1

1 4 2 5

4 2

4 2 1 5

4 3

5 2 4 1

4 4

1 2 4 5

SAMPLE OUTPUT

Average

Average

Average

Good

8.Gurpreet and Shyamu were playing COD(yes you read right that is Call of Duty).
As you all know Gurpreet is too good in it. Shyamu being jealous give Gurpreet a
problem to solve so that he can clear more missions than him.

The Problem is :

Shyamu gives Gurpreet a string str and q queries.


Each query is of type

k ch

(where k is a positive number and ch is a lowercase character)

In each query Gurpreet has to delete kth occurence of character ch. And at the
end he has to print the string after all queries. As Gurpreet wants to play COD
he give this task to you to solve.

Input :

The first line contains string str, and second line contains q that is number of
queries.

Then q lines consist of queries as above explained.

Output :

A String in single line after performing all queries.

SAMPLE INPUT

agcdgcaag

2 a

1 c

1 d

3 g

2 a

SAMPLE OUTPUT

aggc

Convert a number in decimal form to the equivalent mixed number with the fraction portion
reduced to lowest terms.
Input: There are an unknown number of values on a single line. A –1 is used to indicate the end of
the data set.
Output: Output the integer part of the number, followed by the word AND where the decimal point
was, and then the reduced fraction. There is to be a division symbol (/) between the numerator and
the denominator of the fraction.
The output is to be formatted exactly like that for the sample output given below.
Assumptions: The numbers are in the range 1..500. There are no repeating decimals.
The –1 used to indicate the end of the data set is not part of the data for the problem.
Sample Input:
2.95 14.2 5.625 -1
Sample Output:
2 AND 19/20
14 AND 1/5
5 AND 5/8

You might also like