Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Add two polynomials:

Input

The first line contains a single integer M.

Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.

After that next line contains a single integer N.

Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.

Output

Print the addition of polynomials A and B.

The format for printing polynomials is: Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is co-efficient and C0 is constant, there will be space before and after the plus or minus sign.

If co-efficient is zero then don't print the term.


.Explanation


If M = 4 and for polynomial A

For power 0, co-efficient is 5

For power 1, co-efficient is 0

For power 2, co-efficient is 10

For power 3, co-efficient is 6.


If N = 3 and for polynomial B

For power 0, co-efficient is 1

For power 1, co-efficient is 2

For power 2, co-efficient is 4.



Prefix Suffix

Write a program to check the overlapping of one string's suffix with the prefix of another string.

Input


The first line of the input will contain a string A.

The second line of the input will contain a string B.

Output


The output should contain overlapping word if present else print "No overlapping".

Explanation


For example, if the given two strings, A and B, are "ramisgood" "goodforall"

The output should be "good" as good overlaps as a suffix of the first string and prefix of next.


Pyramid

Given an integer N, write a program to print a pyramid of N rows as shown below.

Input

The first line of input is an integer N.

Explanation

In the example, the number of rows in the pyramid is

5.So, the output should be


. . . . 0 . . . .

. . . 0 0 0 . . .

. . 0 0 0 0 0 . .

. 0 0 0 0 0 0 0 .

0 0 0 0 0 0 0 0 0


Sample Input 1

5

Sample Output 1

. . . . 0 . . . .

. . . 0 0 0 . . .

. . 0 0 0 0 0 . .

. 0 0 0 0 0 0 0 .

0 0 0 0 0 0 0 0 0

Sample Input 2

6

Sample Output 2

. . . . . 0 . . . . .

. . . . 0 0 0 . . . .

. . . 0 0 0 0 0 . . .

. . 0 0 0 0 0 0 0 . .

. 0 0 0 0 0 0 0 0 0 .

0 0 0 0 0 0 0 0 0 0 0




Digit 9

You are given N as input. Write a program to print the pattern of 2*N - 1 rows using an asterisk(*) as shown below.

Note: There is a space after each asterisk * character.

Input

The first line of input is an integer N.

Explanation

In the given example,

N = 4.So, the output should be


* * * *

* *

* *

* * * *

*

*

* * * *


Sample Input 1

4

Sample Output 1

* * * *

* *

* *

* * * *

*

*

* * * *

Sample Input 2

5

Sample Output 2

* * * * *

* *

* *

* *

* * * * *

*

*

*

* * * * *




Shaded Diamond

Given an integer value N as input, write a program to print a shaded diamond of 2*N -1 rows using an asterisk(*) character as shown below.

Note: There is a space after each asterisk (*) character.

Input

The first line of input is an integer N.

Explanation

In the given example

N = 5. Therefore, the output should be

*

* *

* * *

* * * *

* * * * *

* *

* *

* *

*


Sample Input 1

6

Sample Output 1

*

* *

* * *

* * * *

* * * * *

* * * * * *

* *

* *

* *

* *

*

Sample Input 2

5

Sample Output 2

*

* *

* * *

* * * *

* * * * *

* *

* *

* *

*




Write a python program that asks the user to give a movie’s budget and its total
domestic and international collection. Then your program should calculate the profit of
the movie. Then print the information according to the provided chart below.
Profit = domestic + international - budget

Profit Information to be printed
•No profit Super flop movie!!
•Less than 500000 (5 lakh) Flop movie!
Waste of money. Waste of time.
•Greater than 5 lakh and
less than 20 lakh Average movie
•Above 20 lakh Success!!
•Above 30 lakh Super Hit!!!

Sample Input 1:
50000
1000000
800000
Sample Output 1:
Profit: 1750000
Average movie

In math notation, leading zeros are OK, as in 02. What happens if you try this in Python and why


Number Diamond

Given an integer N as input, write a program to print a number diamond of 2*N -1 rows as shown below.

Note: There is a space after each number.

Input

The first line of input is an integer N.

Explanation

In the given example, the number of rows in the diamond is

5.So, the output should be


1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

1 2 3 4

1 2 3

1 2

1


Sample Input 1

5

Sample Output 1

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

1 2 3 4

1 2 3

1 2

1

Sample Input 2

4

Sample Output 2

1

1 2

1 2 3

1 2 3 4

1 2 3

1 2

1




Indivisible Numbers

You are given a positive integer N. Your task is to find the number of positive integers K <= N such that K is not divisible by any of the following numbers 2, 3, 4, 5, 6, 7, 8, 9, 10.

Input

The first line of input is an integer N.

Output

The output should be an integer representing the number of positive integers satisfying the above condition.

Explanation

In the given example,

11 is not divisible by any number from 2 to 10. It is divisible by only 1, 11.So, the output should be

2.

Sample Input 1

11

Sample Output 1

2

Sample Input 2

12

Sample Output 2

2

Sample Input 3

200

Sample Output 3

47

Sample Input 4

10

Sample Output 4

1




Hollow Rectangle - 2

Write a program to print a rectangle pattern of M rows and N columns using the characters as shown below.

Input

The first line of input is an integer M. The second line of input is an integer N.

Explanation

In the given example,

3 rows and 10 columns.

Therefore, the output should be


+----------+

| |

| |

| |

+----------+


Sample Input 1

3

10

Sample Output 1

+----------+

| |

| |

| |

+----------+

Sample Input 2

5

10

Sample Output 2

+----------+

| |

| |

| |

| |

| |

+----------+




LATEST TUTORIALS
APPROVED BY CLIENTS