TopCoder Forums RSS Feed
http://apps.topcoder.com/forums/
Most recent forum messagesenSun, 21 Oct 2018 21:16:48 -0400Re: Counting permutations of certain type
http://apps.topcoder.com/forums/?module=Message&messageID=2094678
clickme]]>shpendktesterSat, 30 Jan 2016 07:38:00 -0500Sat, 30 Jan 2016 07:38:00 -0500Sat, 30 Jan 2016 07:40:39 -0500shpendktester0Re: Counting permutations of certain type
http://apps.topcoder.com/forums/?module=Message&messageID=1961419
rit2012008Sat, 13 Dec 2014 10:47:27 -0500Sat, 13 Dec 2014 10:47:27 -0500Sat, 13 Dec 2014 10:47:27 -0500rit20120081Re: Counting permutations of certain type
http://apps.topcoder.com/forums/?module=Message&messageID=1780310
dimkadimonThu, 19 Sep 2013 03:20:10 -0400Thu, 19 Sep 2013 03:20:10 -0400Thu, 19 Sep 2013 03:20:10 -0400dimkadimon0Counting permutations of certain type
http://apps.topcoder.com/forums/?module=Message&messageID=1773724
This is my first post here and I really need some help with this. I know this problem might be silly for many of you :) but I couldn't solve it, so need your help.

I am given 2 integers 1st one: N, I have to consider all permutations of numbers from 1 to N 2nd one: M, I have to count only those of the set of permutations in which no sum of adjacent numbers are dividable by M

Example: Input: 3 3 Output: 2 The set of all permutations is 1. 1 2 3 2. 1 3 2 3. 2 1 3 4. 2 3 1 5. 3 1 2 6. 3 2 1 But I can take only 2 and 4 because all the others have adjacent numbers whose sum is dividable by 3. So the output is 2.

The maximum value of N is 14 and for M is 30 Is there any efficient way of doing this?? Please note that, I know how to generate all the permutations and get the result using bruteforce. But given the constraints, this will take hours if not days. But some teams solved it on a single attempt in a local contest and I'm really out of ideas here. Please help..]]>TafhimSat, 31 Aug 2013 08:44:01 -0400Sat, 31 Aug 2013 08:44:01 -0400Sat, 31 Aug 2013 08:46:25 -0400Tafhim2