719 views

Uploaded by Manoj Prabhakar

Cadbury Problem

Cadbury Problem

© All Rights Reserved

- TCL User's Guide
- AES Computational Hydraulics for Civil Engineers
- Solutions Manual
- Custom Macro B
- fortranv9
- Td Win32asm 220.Asm
- ECL module pool.ppt
- 1Optimization Process of Reading & Writing of SAP HR Master Data Through Buffers
- tdd
- SAP ABAP Online Training | Online SAP ABAP Training | SAP ABAP Online Course
- MD050_Functional Design Template
- HOTS-XII-I.P
- Keil C Programming Tutorial
- read_text
- Multiuser Programming
- Logo Tutorial
- Horse Model
- Ucla Pso Manual
- AB1012 - Enhancements - Exits - V1.0
- 4.REPORTS

You are on page 1of 3

In DPS School, Cadbury bars have to be distributed to children waiting in a queue. Each

Cadbury bar is rectangular in shape. Consider its side lengths are integer values.

The distribution procedure is as follows:1. If bar is not square in shape, then the largest possible square piece of Cadbury is

broken and given to the first child in queue.

2. If bar is square in shape, then complete bar is given to the first child in queue.

Once a child receives his share of Cadbury, he leaves the queue. The remaining portion

of the Cadbury bar is dealt in same fashion and the whole or a portion of it is given to the

next child in the queue.

School has got a carton of Cadbury bars to be distributed among the children all over the

School. The Cadbury bars in the carton are of different sizes. A bar of length i and

breadth j is considered to be different from a bar of length j and breadth i.

For every i such that M<=i<=N and every j such that P<=j<=Q (where M, N, P and Q are

integers). Each Cadbury bar in carton is unique in length (i) and breath(j).

Given the values of M, N, P and Q (where M, N values are the ranges for length of

Cadbury and P, Q values are the ranges for breadth of Cadbury). Find the number of

children who will receive Cadbury from the carton.

Input Specification:

M, N, P, Q are of integer type (M, N values are the ranges for length of Cadbury bar. P, Q

values are the ranges for breadth of Cadbury bar).

Output Specification:

Number of children who will receive Cadbury bar from the carton.

M = 5, N = 6, P = 3, Q=4

Here, i can be from 5 to 6 and j can be from 3 to 4. So the four bars will be in carton of

sizes 5x3, 5x4, 6x3, 6x4.

First we choose a cadbury bar of size 5x3

first child would receive 3x3 portion ( remaining 2x3 portion )

next child would receive 2x2 portion ( remaining 2x1 portion )

now the remaining portion are 2 square pieces of (1x1), which can be given to 2 more

children

So the Cadbury bar with the size of 5x3 can be distributed to 4 children.

Similarly we can find out number of children for rest of the combinations (i.e. 5x4, 6x3,

6x4) in the given range as follows

Cadbury bar with the size of 5x4 can be distributed

Cadbury bar with the size of 6x3 can be distributed

Cadbury bar with the size of 6x4 can be distributed

to 4 children.

to 5 children.

to 2 children.

to 3 children.

So the whole carton can be distributed among 14 children. Hence the output will be 14.

Instructions:

1) Do not write main function.

2) You can print and debug your code at any step of the code.

3) You need to return the required output from the given function.

4) Do not change the function and parameter names given in editor code.

5) Return type must be the same as mentioned in the problem statement.

6) When you submit your code, 10 test cases of different complexity level are executed

in the background and marks are given based on number of test cases passed.

7) If you do not plan to complete the code in one sitting, then please save your work on a

local machine. The code is saved only when it has been submitted using Submit button.

8 ) Only one submission is allowed.

Crazy crow

There are N pots. Every pots have some water in it. They may be partially filled. So there is a

Overflow Number O associated with every pot which tell how many minimum stone pieces are

require for that pot to overflow. So if for a pot O-value is 5 it means minimum 5 stone pieces

should be put in that pot to make it overflow. Initially a crow watched those pots and by seeing

the water level he anticipated O-value correctly for every pot ( that is he knew O1 to On). But

when he came back in evening he found that every pot is painted from outside and he is not able

to know which pot has what O-value. Crow wants some K pots to overflow so that he can serve

his child appropriately. For overflow of pots he need to search for stone in forest( assume that

every stone has same size). He wants to use minimum number of stones required to overflow K

pots. But only he know the O-value of pots he doesn't know now which pot has what O-value. So

the task is that in what minimum number of stones he can make K pots overflow in worst case.

Input Specification:1) A array O corresponding to O-value of N pots {O1, O2, ....... , On}2)

Number of pots3) K -value ( number of pots which the crow wants to overflow}

Output Specification:Minimum number of stones required to make K pots overflow in worst

case.or-1 if input is invalid

Example:

Let say there are two pots

pot 1 has O value of 5 , O1= 5pot 2 has O value of 58, O2= 58

Let say crow wants to make one of the pot to overflow. If he know which pot has what O-value

he would simple search for 5 stones and put then in pot 1 to make it overflow. But in real case he

doesn't know which pot has what O-value so just 5 stones may not always work. However he

does know that one pot has O-value 5 and other has 58. So even in worst case he can make one

of the pot overflow just by using 10 stones. He would put 5 stones in one pot if it doesn't overflow

he would try the remaining 5 in the other pot which would definitely overflow because one of the

pot has O-value of 5.So the answer for above question is minimum 10 stones even in worst

case.

Input : Input 1= {5,58}Input 2= 2

Input 3= 1 Output : 10

Instructions: 1) Do not write main function. 2) You can print and debug your code at any step of

the code.3) You need to return the required output from the given function. 4) Do not change the

function and parameter names given in editor code.5) Return type must be the same as

mentioned in the problem statement. 6) When you submit your code, 10 test cases of different

complexity level are executed in the background and marks are given based on number of test

cases passed. 7) If you do not plan to complete the code in one sitting, then please save your

work on a local machine. The code is saved only when it has been submitted using Submit

button. 8 ) Only one submission are allowed.

- TCL User's GuideUploaded byrivasbc
- AES Computational Hydraulics for Civil EngineersUploaded byleandromituni
- Solutions ManualUploaded byNguyễn Tấn Tài
- Custom Macro BUploaded byikebud
- fortranv9Uploaded byDarren Pinto
- Td Win32asm 220.AsmUploaded byz4rm4r
- ECL module pool.pptUploaded byAnonymous 0v9zwXz6hF
- 1Optimization Process of Reading & Writing of SAP HR Master Data Through BuffersUploaded bysudheer
- tddUploaded byCleisaxolocolvtwo Anderson
- SAP ABAP Online Training | Online SAP ABAP Training | SAP ABAP Online CourseUploaded bySap Rams
- MD050_Functional Design TemplateUploaded bypdesiraju
- HOTS-XII-I.PUploaded bylapogk
- Keil C Programming TutorialUploaded byBhautik Daxini
- read_textUploaded byRasika Jayawardana
- Multiuser ProgrammingUploaded byWilliam Limanjaya
- Logo TutorialUploaded byPeroJurevic
- Horse ModelUploaded byPrashanth
- Ucla Pso ManualUploaded byhymu315376
- AB1012 - Enhancements - Exits - V1.0Uploaded byArpit Choudhary
- 4.REPORTSUploaded byPankaj Chauhan
- Classical ALV Reporting - Overview of ALVUploaded bytopankajsharma
- _INVDRT401_WriteParameterUploaded byJoseph
- Fortran 90 ProgramsUploaded byAnonymous YwecsKD
- impl_planUploaded byKanika Dhamija
- Lab2Uploaded byJose Miranda
- NotesUploaded byjames
- Visual BasicUploaded bykent
- Bapi Inspoper RecordresultsUploaded byvtheamth
- handout1Uploaded bygdeepthi
- ABAP Int QuestionsUploaded byghulam mohammed

- Presentation 1Uploaded byManoj Prabhakar
- Doc checkUploaded byManoj Prabhakar
- Canal ConstructionUploaded byAnuranga Sahampath
- Cross_Section.pdfUploaded byana
- 2_33_580_1866266Uploaded byManoj Prabhakar
- ACR Form for Class-IV Employees 170117Uploaded byManoj Prabhakar
- Doc Upload1Uploaded byManoj Prabhakar
- UGC Solution IUploaded byManoj Prabhakar
- mcq compUploaded byManoj Prabhakar
- PDFDec2015_Paper III_D 8715 Paper III Computer Science and ApplicationUploaded byManoj Prabhakar
- Civil 15jan2014Uploaded byManoj Prabhakar
- Current Exam PapersUploaded byManoj Prabhakar
- OBC - Recruitment of Specialist OfficersUploaded byManoj Prabhakar
- Harya WarehouseUploaded byManoj Prabhakar
- User ManualUploaded byAmanpreet Singh
- Statement ConclusionUploaded byManoj Prabhakar
- Hibernate Interview Questions Part1Uploaded byManoj Prabhakar
- ccbsUploaded byManoj Prabhakar
- Document 2Uploaded byManoj Prabhakar
- APPlicaton Medical Leave FormUploaded byManoj Prabhakar
- 1 Nobel PrizesUploaded byManoj Prabhakar
- _65-67_ Gk Bytes PunjabUploaded byManoj Prabhakar
- PropertyUploaded byManoj Prabhakar
- Strivector Recruiter Trainee Test.docUploaded byManoj Prabhakar
- hhiUploaded byManoj Prabhakar
- TA RULES 04_2014Uploaded byManoj Prabhakar
- Haryana RoadwaysUploaded byManoj Prabhakar
- Discrete Mathematical Structures 4ed (4)Uploaded byLxr Animoos Poor E
- system-software-and-operating-system.pdfUploaded byAsad Ejaz

- DotNetVJC TutorialUploaded byMAYUR SHUKLA
- How Does Data Communication Work Between S7-300 S7- 400 and S7-200 via MPI Using S7 Www.otomasyonegitimi.comUploaded bywww.otomasyonegitimi.com
- Weatherwax Pacheco ProblemsUploaded bynarendra
- Figaro TutorialUploaded byKee
- Intel Cheat SheetUploaded bywmcscrooge
- Introduction to Function in SynonUploaded byVijay Kumar
- Appendix E Key Concepts of the IBIS Model_Appendix E2 3Com Internal IBIS SpecUploaded byfa_a2z
- 1Uploaded byengr_n_n_malik
- KX-TA824 Programming ManualUploaded byCristhian Uscocovich
- Algorithmic Problem Solving With PythonUploaded byMariaJose Cote Lays
- Visual Basic Multiple Choice Questions and AnswersUploaded byMarites Paragua
- JSP Request Object MethodsUploaded byBiswabrata Banerjee
- shellscrpitsUploaded byAnkit Singh
- SparcoUploaded byuranub
- flujometro BA094DEN_1108Uploaded byÓscar Sanhueza
- Sercans ErrorsUploaded bycyrus6_997303
- SNEPSCHEUT Proxac an Editor for Program TransformationUploaded byP6E7P7
- 11103 Lecture SlidesUploaded byjhghghghgf
- Nodejs_Succinctly.pdfUploaded byHu Em Ai
- SCL siemensUploaded byBenedict Jo
- final_sem_1_v2_PLSQL.docUploaded byBeckhs Bks
- Manual ROSADITO TV XDUploaded byRafael M. Mory
- Transform Your Data Integration Platform From Informatica to ODI WebinarUploaded byJade Global
- Simoreg dc masterUploaded bySivaprasad Kc
- system verilogUploaded byBalasubrahmanya VaRma Dandu
- AME1_REV11Uploaded byG.s. Vishwanth
- pc400_man.pdfUploaded byfredo yoga
- C++ for PhysicistUploaded bydoppler9effect
- Wm Configuration GuideUploaded byAg Sri
- 141303Uploaded byKeerthu Cherryl