You are not logged in. Please login at www.codechef.com to post your questions!

×

Enigma2018

Can someone please explain me the approach to solve this problem https://www.codechef.com/PLCO2018/problems/KILLLAZ

asked 18 Jan '18, 17:54

kunal12's gravatar image

3★kunal12
445
accept rate: 0%


You need to arrange N numbers, and the arrangement must contain a given subsequence of length M. First of all, check if its possible, ie., if all the M numbers are distinct. Then, since the order in which the M numbers appear is fixed, we just need to find the number of ways in which you can put the other N-M numbers in N positions. After that, the remaining M numbers will be placed in the leftover spaces.

The number of ways in which you can put N-M numbers in N positions is Np(N-M) = N!/M!.

link

answered 18 Jan '18, 18:35

hemanth_1's gravatar image

6★hemanth_1
1.4k12
accept rate: 28%

If some elements in the m sized array are same then the answer would be zero right ? Else n!/m!

(18 Jan '18, 19:33) kunal123★
(18 Jan '18, 20:45) hemanth_16★
1

Got it... thankyou @hemanth_1 :)

(18 Jan '18, 22:04) kunal123★

Suppose you have n=4,m=2 . You can place the remaining 2 elements in 4 * 3 ways. For n=5,m=2 ,you can place the remaining 3 elements in 5 * 4 * 3 ways.Observed some pattern?Rest I'll leave it to you to know how. You can refer this Code

link

answered 18 Jan '18, 18:44

stranger7's gravatar image

5★stranger7
1464
accept rate: 27%

edited 18 Jan '18, 18:45

Access is denied to this code :/

(18 Jan '18, 18:49) kunal123★

Who to approach this one from the same contest, help please https://www.codechef.com/PLCO2018/problems/PRMSWP

link

answered 21 Jan '18, 15:46

merajeev's gravatar image

2★merajeev
11
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×191

question asked: 18 Jan '18, 17:54

question was seen: 350 times

last updated: 21 Jan '18, 15:46