1.Problem : Digital Time 12 The objective is to form the maximum possible time in the HH:MM:SS format using an six of nine given single !igits "not necessaril !istinct# $iven a set of nine single "not necessaril !istinct# !igits% sa &% &% 1% '% (% )% *% +% ,% it is possible to form man !istinct times in a 12 hour time format HH:MM:SS% such as 1&:'):(& or &1:',:() b using each of the !igits onl once. The objective is to fin! the maximum possible vali! time "&&:&&:&1 to 12:&&:& that can be forme! using some six of the nine !igits exactl once. -n this case% it is 1&:(,:'+. -nput line consisting of a se/uence of , "not necessaril !istinct# single !igits "an of &0,# separate! b commas. The se/uence ill be non0!ecreasing utput The maximum possible time in a 12 hour cloc3 "&&:&&:&1 to 12:&&:& in a HH:MM:SS form that can be forme! b using some six of the nine given !igits "in an or!er# precisel once each. -f no combination of an six !igits ill form a vali! time% the output shoul! be the or! 0 -mpossible 4xample 1 -nput: &%&%1%1%'%5%)%*%* utput: 11:5*:'* The maximum vali! time in a 12 hour cloc3 that can be forme! using some six of the , !igits precisel once is 11:5*:'* 4xample 2 -nput: '%'%'%'%'%'%'%'%' utput: -mpossible 6o set of six !igits from the input ma be use! to form a vali!
time.
2.Problem : Prime numbers spelt ith prime number of letters -f ou li3e numbers% ou ma have been fascinate! b prime numbers. These are numbers that have no !ivisors other than 1 an! themselves. -f e consi!er the primes 2 an! '% an! rite them in or!s% e rite T7 an! TH844. 9oth have a prime number of letters in their spelling. 6ot all prime numbers have this propert. 7rite a program to count the number of primes beteen a given pair of integers "inclu!ing the given integers if the are primes# that have a prime number of characters hen ritten in or!s. The blan3s are not counte! hen e rite the numbers in or!s. or example% 64 H;6D84D 6D TH844 has onl 1+ characters. -nput ne line containing to integers separate! b space giving 61 an! 62 utput ne integer M giving the number of primes P such that 61 <= P <= 62 that are such that hen P is ritten in or!s% it has a prime number of letters. >onstraint 62 <= ,,,,, 4xample 1 -nput: 1 1& utput: ' 4xplanation: The primes beteen 1 an! 1& an! 2% '% 5 an! *. f these% 5 ritten in or!s is -?4 an! has a non prime number of letters an! others have prime number of letters "vi@ T7% TH844 an!
S4?46#. 4xample 2 -nput: 11&& 11'& utput: 1 4xplanation: The primes beteen 11&& an! 11'& are 11&'% 11&,% 111*% 112' an! 112,. 7hen these are ritten in or!s% e get 64 TH;S6D 64 H;6D84D 6D TH844 64 TH;S6D 64 H;6D84D 6D 6-64 64 TH;S6D 64 H;6D84D 6D S4?46T446 64 TH;S6D 64 H;6D84D 6D T746TA TH844 64 TH;S6D 64 H;6D84D 6D T746TA 6-64 The count of characters in the above are 2,% 2+% ''% '5 an! '( f these onl for 11&' the count of characters is prime.
'.Problem : ibonacci 8ight Triangles The ibonacci series 1%1%2%'%5%+%... is ell 3non. -n this series% if n is the nth number 1=1% 2=1% n=n01Bn02 4ver alternate number in the series stating ith 5 "5%1'%'(%...# can be the hpotenuse of a right angle! triangle. 7e call each of these a ibonacci 8ight ngle! Triangle% or 8T for short. The larger of the remaining to si!es is the nearest integer to "2Cs/rt"5## times the hpotenuse. factor of a positive integer is a positive integer ith !ivi!es it completel ithout leaving a remain!er. or example% for the number 12% there are ) factors 1% 2% '% (% )% 12. 4ver positive integer 3 has at least to factors% 1 an! the number 3 itself. The objective of the program is to fin! the number of factors of the even si!e of the smallest 8T hose hpotenuse is o!! an! is larger than a given number -nput
The input is a positive integer 6 utput The number of factors of the even si!e of the smallest 8T hich has an o!! hpotenuse greater than 6 >onstraints The even si!e is less than 5&&&&&& 4xample 1 -nput: 1& utput: ) 4xplanation: The smallest 8T that has an hpotenuse greater than 1& is "1'%12%5#. s the hpotenuse is o!!% e ta3e this. The even si!e is 12% factors are "1%2%'%(%)%12#% a total of ) factors. The output is ) 4xample 2 -nput: 2& utput: 1& 4xplanation: The smallest 8T that has an "'(%'&%1)#. s the hpotenuse hich is "+,%+&%',#. The even "1%2%(%5%+%1&%1)%2&%(&%+% a 1&
hpotenuse greater than 2& is is even% e ta3e the next 8T% si!e is +&% factors are total of 1& factors. The output is
(.Problem : Smallest Multiple in permute! !igits $iven to integers 6% ! % fin! the smallest number that is a
multiple of ! that coul! be forme! b permuting the !igits of 6. Aou must use all the !igits of 6% an! if the smallest multiple of ! has lea!ing @eros% the can be !roppe!. -f no such number exists% output 01. -nput line containing to space separate! integers% representing 6 an! !. utput single line giving the permutation of 6 that is the smallest multiple of !% ithout an lea!ing @eroes% if an. -f not such permutation exists% the output shoul! be 01 >onstraints 1≤6≤1&&&&&&&&&&&& 1≤!≤1&&&&&& 4xample 1 -nput 21& 2 utput 12 4xample 2 -nput 1*&*),'15+ +5')+( utput 51',1**)+ 4xample ' -nput 5'1 2 utput 01 4xplanation 1. -n first test case the minimum number forme! using all the three !igits !ivisible b the given !ivisor is &12 hich is
e/uivalent to 12 an! this is a multiple of ! = 2. Hence the output is 12. 2. -n secon! test case the minimum number forme! using all the !igits !ivisible b the given !ivisor is &51',1**)+. So in this case the output ill be 51',1**)+. '. -n the last case all permutations of !igits of 6 are o!! an! hence not !ivisible b !.
5.Problem : >omplicate! 9omb Drop $ame T>S -n!ia has !evelope! a funn an! entertaining game. 7hen ou begin% the screen contains a number of lines. n enem plane !rops a bomb of certain ra!ius 8 at a certain location "x%# on the screen an! all the portions of the lines that are ithin a circle of
ra!ius 8 ith center "x%# are !estroe!.
fter the bomb !estros the portions of the lines% compute the sum of the lengths of the lines remaining. -nput The input consists of 6B' lines% here 6 is the number of lines. The first line is 6% the number of lines. The secon! line is 8% the ra!ius of the bomb The thir! line contains the coor!inates of the point at hich the bomb is !roppe!% as a pair of space separate! integers "x an! # The next 6 input lines contain the coor!inates of the start an! the en! of a line on the screen. This is a set of ( space separate! integers "ma be negative or representing the x an! coor!inates of the starting an! en!ing point respectivel of the line on the screen. utput single line containing the sum of the lengths of the resi!ual lines. This must be expresse! as a number correct to to !ecimal
places. 6ote that the output must alas be shon ith to !ecimal places even if the resi!ual length is an integer. Thus% if the resi!ual length is 1)% the output must be 1).&&% an! if the resi!ual length is &% the output must be shon as &.&& >onstraints 1<6<2& 01&&&
fter the bomb is !roppe! at "2%(# ith ra!ius (% the position on the screen is
There are ( lines% each of length (% an! hence% the total resi!ual length is 1). The output is 1).&& 4xample 2 -nput: * ( ' 5 ' , ' 1' ' 0' ' 015 ( , 1) , 01 , 011 , 11 1' ' 5 , + ( ) 01 5 05 5 utput: 52.&(
4xplanation: There are initiall * lines% an! the bomb is !roppe! at "'%5# ith a ra!ius (. nl the fifth an! sixth lines are affecte! b the bomb% an! become *.'1 an! 2.*2 in length. The total resi!ual length "correct to to !ecimals is 52.&(% hich is the output.
).Problem : >ounting S/uares Mr Smith% the Mathematics teacher for Stan!ar! ?-% is an exasperate! person. He ants to !evice a a to 3eep his class of excite! stu!ents /uiet% so he can catch a bit of sleep "he ent to late night shoing of 9aahubali 2 the previous night#. He !re ten e/uall space! hori@ontal lines an ten e/uall space! vertical lines so that the forme! 1&& 1 x 1 s/uares. He then erase! at ran!om various segments of lines joining points of the gri!% an! as3e! the class to count s/uares of all si@es ith si!es along the lines that are remaining on the boar!. He believe! that this oul! ta3e at least an hour. The class ha! been taught programming in the summer% an! so some stu!ents /uic3l rote some co!e to count the s/uares% an! Mr Smith !i! not get much sleep >an ou emulate the stu!entsE Aou ill be given a set of 6 hori@ontal an! vertical lines ith some missing segments. Aou nee! to count the number of s/uares of all si@es "1 x 1% 2 x 2% ... 6 x 6# ith si!es full present in the remaining lines.
The above% for example is a set of ( hori@ontal an! ( vertical e/uall space! lines ith a number of segments remove!. 7e nee! to count s/uares of all si@es ith si!es along the remaining lines -nput The first line of the input is a positive integer 6 giving the number of hori@ontal an! vertical lines. The secon! line is a non0negative number m giving the number of segments remove!. Then there are m lines% each containing ?%i%j or H%i%j% here i
an! j are positive integers. H%i%j in!icates a hori@ontal gap in the ith hori@ontal line beteen the jth an! "jB1#th point on the line. ?%i%j represents a gap in the ith vertical line beteen the jth an! "jB1#th point on the line. utput The output is a single line giving the total number of s/uares in the figure% ith si!es along the remaining lines in the figure >onstraints (≤6≤2& &≤m≤(& -≤6 F≤"601# 4xample 1 -nput ( ( H%2%1 H%'%1 ?%2%2 ?%2%' utput 5 4xplanation There are ( vertical an! hori@ontal lines% an! ( line segments missing. The first missing hori@ontal segment is on the secon! hori@ontal line% beteen the first an! secon! point% an! the other missing hori@ontal segment is on the thir! hori@ontal line at the same position. The to missing vertical segments are on the secon! vertical line% an! beteen the secon! an! thir!% an! the thir! an! fourth points respectivel. -t can be seen that this !escribes the above figure. There is one ' x ' s/uare% @ero 2 x 2 s/uares an! four 1 x 1 s/uares% a total of 5 s/uares. Hence the output is 5. 4xample 2 -nput ( 2 ?%2%2 ?%2%'
utput + 4xplanation
-t has four vertical lines an! four hori@ontal lines. To vertical segments are missing% on the secon! line% beteen the secon! an! thir! point an! the thir! an! fourth point. There is one 'x' s/uare% to 2 x 2 s/uares an! five 1 x 1 s/uares ith si!es along the remaining lines. Hence there are a total of + s/uares remaining% an! the output is +.