# Chefina and Swap SOLUTIONS CHFNSWAP

## Chefina and Swap SOLUTION

You are given a positive number N. Consider the grouping S=(1,2,… ,N). You ought to pick two components of this succession and trade them.

A trade is decent if there is a number M (1≤M<N) with the end goal that the whole of the primary M components of the subsequent succession is equivalent to the aggregate of its last N−M components. Locate the quantity of pleasant trades.

Info

The main line of the info contains a solitary number T meaning the quantity of experiments. The portrayal of T experiments follows.

The solitary line of each experiment contains a solitary number N.

Yield

For each experiment, print a solitary line containing one number ― the quantity of decent trades.

Imperatives

1≤T≤106

1≤N≤109

T≤10

N≤103

T≤10

N≤106

Subtask #3 (60 focuses): unique imperatives

Model Input

Model Output

3

LOGIC VIDEO HAS BEEN REMOVED

### 31 thoughts on “Chefina and Swap SOLUTIONS CHFNSWAP”

1. Is it need any algorithm or it's implementation based question?

2. I think when there will be 3 days to end or 5 days then i think this codechef may permit till then i think we need to try our own put please share any logic we dont want code just logic will do thanks man

3. hey bro i think its not based on algorithm totally i think we need to find out the logic even in trying if u can do it please share the solutions here

4. hello can someone just tell me what would be the answer input 20 please, it would help me understand the problem statement.

5. #include
using namespace std;

int main()
{
int t;
cin>>t;

while(t–)
{
int n,num;
cin >> n;

num = (n+1)/2;

if(num%2)
cout<<"0"<<endl;
else
cout<<(num/2)+1<<endl;
}
return 0;
}

Can someone point out the mistake?

6. For n=7
output must be 3

7. this is not the correct logic

8. What is the output for n=12 and n=20? The example cases given in the question is not presenting the whole picture.

10. # cook your dish here
t=int(input())
import itertools
def chefswap(n,arr):
hell = list(itertools.combinations(range(n), 2))
m=0
for i,j in hell:
c=0
arr[i],arr[j]=arr[j],arr[i]
for k in range(n-1):
arr1=sum(arr[0:k+1:1])
arr2=sum(arr[k+1:n:1])
if arr1==arr2:
c=c+1
if c!=0:
m=m+1
arr[i],arr[j]=arr[j],arr[i]
return m

for _ in range(t):
n=int(input())
arr=[]
for i in range(1,n+1):
arr.append(i)
if n==1 or n==2:
print(0)
else:
result=chefswap(n,arr)
print(result)

There is time limit error.

11. what will be the output of n=8 and n=9? Please tell.

12. 15 and 1 is a nice swap
16 and 2
17 and 3…..

13. How did you get 112 for n=20

14. How did you get 112 for n=20 please clarify my doubt

15. How did you get 112 for n=20?