[go: up one dir, main page]

0% found this document useful (0 votes)
71 views14 pages

Week1 Assignment

Uploaded by

Sonu Sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views14 pages

Week1 Assignment

Uploaded by

Sonu Sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Week – 1 Assignment

Problem 1

Number Mirror
Write a program that takes a number 𝑁N as the input, and prints it to the output.

Input Format
The only line of input contains a single integer.

Output Format
Output the answer in a single line.

Constraints
• 0≤𝑁≤1050≤N≤105

Sample 1:
Input
Output
123
123

Explanation:

The input is 123. So the output is also 123.

Sample 2:
Input
Output
15
15

Explanation:

The input is 15. So the output is also 15.


Problem 2

Currently there are courses for 4 languages, and hence there are 8 courses in this section.
But suppose there are courses for 𝑁N languages, what will be the total number of courses
in this section?

Input Format
The only line of input will contain a single integer 𝑁N, denoting the number of languages for which
there are courses.

Output Format
Output on a single line the total number of courses in the section.

Constraints
• 1≤𝑁≤1001≤N≤100

Sample 1:
Input
Output
4
8

Explanation:
If there are 44 languages, then there will be 2∗4=82∗4=8 courses in total.

Sample 2:
Input
Output
9
18

Explanation:
If there are 99 languages, then there will be 2∗9=182∗9=18 courses in total.
Problem 3

Chef and Instant Noodles


Chef has invented 11-minute Instant Noodles. As the name suggests, each packet takes
exactly 11 minute to cook.
Chef's restaurant has 𝑋X stoves and only 11 packet can be cooked in a single stove at any
minute.
How many customers can Chef serve in 𝑌Y minutes if each customer orders
exactly 11 packet of noodles?

Input Format
• The first and only line of input contains two space-separated integers 𝑋X and 𝑌Y — the
number of stoves and the number of minutes, respectively.

Output Format
• Print a single integer, the maximum number of customers Chef can serve in 𝑌Y minutes

Constraints
• 1≤𝑋,𝑌≤10001≤X,Y≤1000

Sample 1:
Input
Output
3 7
21

Explanation:
Chef cooks for 𝑌=7Y=7 minutes and can cook 𝑋=3X=3 packets per minute, one on each stove.
So, the total number of packets that can be cooked is 𝑋⋅𝑌=3⋅7=21X⋅Y=3⋅7=21.
Each person orders one packet, so the maximum number of customers that can be served is 2121.
Sample 2:
Input
Output
7 8
56

Explanation:
Chef cooks for 𝑌=8Y=8 minutes and can cook 𝑋=7X=7 packets per minute, one on each stove.
So, the total number of packets that can be cooked is 𝑋⋅𝑌=7⋅8=56X⋅Y=7⋅8=56.
Each person orders one packet, so the maximum number of customers that can be served is 5656.
Problem 4

Chef and Brain Speed


In ChefLand, human brain speed is measured in bits per second (bps). Chef has a threshold
limit of 𝑋X bits per second above which his calculations are prone to errors. If Chef is
currently working at 𝑌Y bits per second, is he prone to errors?
If Chef is prone to errors print YES, otherwise print NO.

Input Format
The only line of input contains two space separated integers 𝑋X and 𝑌Y — the threshold limit and
the rate at which Chef is currently working at.

Output Format
If Chef is prone to errors print YES, otherwise print NO.
You may print each character of the string in uppercase or lowercase (for example, the
strings yes, Yes, yEs, and YES will all be treated as identical).

Constraints
• 1≤𝑋,𝑌≤1001≤X,Y≤100

Sample 1:
Input
Output
7 9
YES

Explanation:
Chef's current brain speed of 99 bps is greater than the threshold of 77 bps, hence Chef is prone to
errors.
Sample 2:
Input
Output
6 6
NO

Explanation:
Chef's current brain speed of 66 bps is not greater than the threshold of 66 bps, hence Chef is not
prone to errors.

Sample 3:
Input
Output
31 53
YES

Explanation:
Chef's current brain speed of 5353 bps is greater than the threshold of 3131 bps, hence Chef is
prone to errors.

Sample 4:
Input
Output
53 8
NO

Explanation:
Chef's current brain speed of 88 bps is not greater than the threshold of 5353 bps, hence Chef is not
prone to errors.
Problem 5

Alice and Marks


Alice has scored 𝑋X marks in her test and Bob has scored 𝑌Y marks in the same test. Alice is
happy if she scored at least twice the marks of Bob’s score. Determine whether she is happy
or not.

Input Format
• The first and only line of input contains two space-separated integers 𝑋,𝑌X,Y — the marks
of Alice and Bob respectively.

Output Format
For each testcase, print Yes if Alice is happy and No if she is not, according to the problem statement.
The judge is case insensitive so you may output the answer in any case. In particular YES, yes,
yEsare all considered equivalent toYes`.

Constraints
• 1≤𝑋,𝑌≤1001≤X,Y≤100

Sample 1:
Input
Output
2 1
Yes

Explanation:
Alice has scored 𝑋=2X=2 marks whereas Bob has scored 𝑌=1Y=1 mark. As Alice has scored twice
as much as Bob (i.e. 𝑋≥2𝑌X≥2Y), the answer is Yes.
Sample 2:
Input
Output
1 2
No

Explanation:
Alice has scored 𝑋=1X=1 mark whereas Bob has scored 𝑌=2Y=2 marks. As Alice has not scored
twice as much as Bob (i.e. 𝑋<2𝑌X<2Y), the answer is No.
Problem 6

Oneful Pairs
Chef defines a pair of positive integers (𝑎,𝑏)(a,b) to be a Oneful PairOneful Pair, if
𝑎+𝑏+(𝑎⋅𝑏)=111a+b+(a⋅b)=111
For example, (1,55)(1,55) is a Oneful PairOneful Pair,
since 1+55+(1⋅55)=56+55=1111+55+(1⋅55)=56+55=111.
But (1,56)(1,56) is not a Oneful PairOneful Pair,
since 1+56+(1⋅56)=57+56=113≠1111+56+(1⋅56)=57+56=113 =111.
Given two positive integers 𝑎a and 𝑏b, output Yes if they are a Oneful PairOneful Pair.
And No otherwise.

Input Format
The only line of input contains two space-separated integers 𝑎a and 𝑏b.

Output Format
Output Yes, if (𝑎,𝑏)(a,b) form a Oneful PairOneful Pair. Output No if they do not.
You may print each character of Yes and No in uppercase or lowercase (for
example, yes, yEs, Yes will be considered identical).

Constraints
• 1≤𝑎,𝑏≤10001≤a,b≤1000

Sample 1:
Input
Output
1 55
Yes

Explanation:
(1,55)(1,55) is a Oneful PairOneful Pair,
since 1+55+(1⋅55)=56+55=1111+55+(1⋅55)=56+55=111.

Sample 2:
Input
Output
1 56
No

Explanation:
(1,56)(1,56) is not a Oneful PairOneful Pair,
since 1+56+(1⋅56)=57+56=113≠1111+56+(1⋅56)=57+56=113 =111
Problem 7

Good Turn
Chef and Chefina are playing with dice. In one turn, both of them roll their dice at once.
They consider a turn to be good if the sum of the numbers on their dice is greater than 66.
Given that in a particular turn Chef and Chefina got 𝑋X and 𝑌Y on their respective dice, find
whether the turn was good.

Input Format
• The first line of input will contain a single integer 𝑇T, denoting the number of test cases.
• Each test case contains two space-separated integers 𝑋X and 𝑌Y — the numbers Chef and
Chefina got on their respective dice.

Output Format
For each test case, output on a new line, YES, if the turn was good and NO otherwise.
Each character of the output may be printed in either uppercase or lowercase. That is, the
strings NO, no, nO, and No will be treated as equivalent.

Constraints
• 1≤𝑇≤1001≤T≤100
• 1≤𝑋,𝑌≤61≤X,Y≤6

Sample 1:
Input
Output
4
1 4
3 4
4 2
2 6
NO
YES
NO
YES
Explanation:
Test case 11: The sum of numbers on the dice is 1+4=51+4=5 which is smaller than 66. Thus, the
turn is not good.
Test case 22: The sum of numbers on the dice is 3+4=73+4=7 which is greater than 66. Thus, the
turn is good.
Test case 33: The sum of numbers on the dice is 4+2=64+2=6 which is equal to 66. Thus, the turn
is not good.
Test case 44: The sum of numbers on the dice is 2+6=82+6=8 which is greater than 66. Thus, the
turn is good.
Problem 8

Water Consumption
Recently, Chef visited his doctor. The doctor advised Chef to drink at least 20002000 ml of
water each day.
Chef drank 𝑋X ml of water today. Determine if Chef followed the doctor's advice or not.

Input Format
• The first line contains a single integer 𝑇T — the number of test cases. Then the test cases
follow.
• The first and only line of each test case contains one integer 𝑋X — the amount of water Chef
drank today.

Output Format
For each test case, output YES if Chef followed the doctor's advice of drinking at least 20002000 ml
of water. Otherwise, output NO.
You may print each character of the string in uppercase or lowercase (for example, the
strings YES, yEs, yes, and yeS will all be treated as identical).

Constraints
• 1≤𝑇≤20001≤T≤2000
• 1≤𝑋≤40001≤X≤4000

Sample 1:
Input
Output
3
2999
1450
2000
YES
NO
YES

Explanation:
Test case 11: Chef followed the doctor's advice since he drank 29992999 ml of water which
is ≥2000≥2000 ml.
Test case 22: Chef did not follow the doctor's advice since he drank 14501450 ml of water which
is <2000<2000 ml.
Test case 33: Chef followed the doctor's advice since he drank 20002000 ml of water which
is ≥2000≥2000 ml.

You might also like