There are N people are sitting around a circular table. Let’s call them P1, P2, . . . , PN , in order. P1 is sitting between P2 and PN . P2 is sitting between P1 and P3. P3 is sitting between P2 and P4, and so on.
You need to select a non-empty subset of these people, such that no two adjacent people are selected. Find the total number of ways in which you can do so.
For example, suppose N = 3, then we have P1, P2 and P3. If we select P1, then neither P2 nor P3 can be selected. So, the only valid selections are {P1}, {P2}, {P3}.
So there are three possible ways, and hence the answer would be 3. Suppose N = 4, then we have P1, P2, P3 and P4. The possible subsets are {P1}, {P2}, {P3}, {P4}, {P1, P3}, {P2, P4}. So the answer would be 6.
Find the answer for the following values of N:
(a) N = 11
(b) N = 13
(c) N = 15
ANS:- (a)198
(b) 520 (c) 1363
This question was from pen & paper test
Answers
Answered by
0
n=int(input())
a=[int(x) for x in input().split(" ")]
l=len(a)
y=[]
for i in range(0,l):
for j in range(0,l):
if(i!=j):
y.append(a[i]%a[j])
y.sort()
l2=len(y)
print(y[l2-1],end='')
Similar questions
Math,
6 months ago
Math,
6 months ago
Computer Science,
1 year ago
Physics,
1 year ago
Math,
1 year ago
Social Sciences,
1 year ago