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

pager


imagine a pager with only one button for the letter "A" you press the button one time for "B"ou press it two times for "E" you press it five times ,for "G" its pressed seven times





explanation :

for example if the given strings abcde , then

the total number of times the button pressed 1+2+4+5


so the output is 12


input: abde

output: 12


intput:xyz

output:75


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.


input:

ramisgood

godforall


output:

good


input-2:

finally

restforall


Ravan's dream is to win tic-tac-toe championship.to accomplish this he practices alone at home to learn the strategies of the game . your task is to identify the cell where Ravan should place his third piece so that he wins the game. Assume that each cell in the tic-tac-toe board is marked with a number as shown in the below


TIC TAC TOE

0 1 2

3 4 5

6 7 8


input:

The first line of input contain two space-seperated integers representing the cells where Ravan has placed his first two pieces


output:

output should be a single line integer representing the cell where ravan should place his final piece


explanation

sample Output 1 :

ravan's first two moves are 0 and 1 so he not 2 to win the game .because it will complete the first row so the out put is 2

sample Output 2 :

ravan's first two moves are 0 and 3 so he not 6 to win the game .because it will complete the first row so the out put is 6



given a of M numbers and a postive integers N, print the sum of numbers whose position in the list is divisible by N .consider that the position of numbers range from 1 to N


INPUT:

the first line contains two-spaced integers N,M

the second line contain M space-seperated integers.


output:

print a single integer representing the requried sum


explanation:

Sample Output1

Given N=1 , M=7

and the number_list=[4,8,6,6,7,9,3]

As every position is divisible by1,

4+8+6+6+7+9+3=43

so the output should be 43


Triples with Properties


Shikhar has two integers S and T. Now, he wants to count al possible triplets of non-negative integers (a, b, c) which satisfy


the below conditions:


-a+b+c<= S -axbxc<=T


Your task is to help him by finding the count of such triplets of non negative integers (a, b, c)


reture cont


T


13 printfomet trip


Input


The only line of input contains two space separated integers S and T


Output


Print the count of triplets of non-pegative integers (a, b, c) satisfying the conditions


Explanation


In the first example, we have $1 and T. O eve 4 triplets of non-negative integers which have the above properties (0,0,0) (0,01), (010) and (100) Therefore, the output is 4


Esc FrLock


2


4


12


4+


Ajith is a raw agent and he is going on a secret mission.He needs your help but you have yo learn how to encode a secret message yo communicate safely with other agents




Cipher with Key





A Keyword Cipher is a monoalpha





uses a key to provide en ption





In a substitution cipher each letter of





matched with a different letter accord to phetet





Using these letter matchings, every letter of the esse





substituted to get the encrypted messag





In a keyword cipher, the key determines the let he ciphertext alphabet is created by keeping the lette the beginning (after removing the repeated letters then the rest of remaining letters are used in aph





For example, if the key is zebras





Plaintext Alphabet: albicidjeifigibili Ciphertext Alphabet : zjelb/r/als/cidition





Notice that with this key, we are able to match each lecer of engl alphabet with a different letter. Using these matchings we can encrypt the word discovered as rpbluacerda





replaced with f,i is replaced with and soon





Given a key K and the message M, encrypt the message Keyword Cipher, using the given key





Input





The first tine contains two

Krishna owns n mobile phones (numbered 1 through n) he wishes to sell all of them in the coming next N years by selling exactly 1 mobile per year. The initial price of each mobile phone is pi . Due to depreciation , the price of each mobile phone decreaes by 2500 rupees per year untill sold.





Note that price of a mobile cannot drop below 1000 rupees no matter how many years have passed , ie when the price of a mobile reaches 1000 rupees in some years , it remains 1000 in all subsequent years .





Find max amount krihna can make by selling his mobile phones





Input




The first line contains a single integer t denoting the number of test cases




The first line of each test case contains a single integer n




The second line of the each test case contains n space seperated integers p1,p2,.....,pn





Output




For each test case , print a single line containing an integer

Evolution stage



If N is even N/2



If N is odd N * 3+1 and point steps to reach 1 . Ex: 10is even 10/2=5, 5 is odd 5*3+1=16, 16 is even 16/2= 8 and 8/2=4 and 4/2= 2 and 2/2 =1



So the output is 6

Discount sale



Input 1


4


1 1 2 2


Output 1


4



Input 2


2


10 200


Output 2


210

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS