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
Subtasks
Subtask #1 (10 focuses):
T≤10
N≤103
Subtask #2 (30 focuses):
T≤10
N≤106
Subtask #3 (60 focuses): unique imperatives
Model Input
5
1
2
3
4
7
Model Output
0
0
2
2
3
LOGIC VIDEO HAS BEEN REMOVED
Is it need any algorithm or it's implementation based question?
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
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
hello can someone just tell me what would be the answer input 20 please, it would help me understand the problem statement.
i think 6
112
#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?
For n=7
output must be 3
but your output will differ
this is not the correct logic
What is the output for n=12 and n=20? The example cases given in the question is not presenting the whole picture.
112
4 and 112
6
hw 112
119-4116
hw
can you please explain how the answer for 20 is 112 please
# 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.
what will be the output of n=8 and n=9? Please tell.
112
3 0
15 and 1 is a nice swap
16 and 2
17 and 3…..
How did you get 112 for n=20
Why 112 for n=20
How did you get 112 for n=20 please clarify my doubt
How did you get 112 for n=20?
what will the output for 11 and 12
please tell fast
4 and 4
It would be 112
It would be 112
What is the answer for 19?
Can you say me how did you get 112 for n=20?
what will be output for n=20?