 # EOOPR - Editorial

Hey Brother,
You cannot change a and b.
Either you can do 2+7+7 (if a = 7) or you can do 2+1+1 (if a = 1 )

Why is it wrong??

https://www.codechef.com/viewsolution/39569192

#include
using namespace std;

int main() {
long long t;
cin>>t;
while(t){
long long x,y,pd;
cin>>x>>y;
if(x==y){
std::cout << “1” << std::endl;
}
else if(y>x){
pd=y-x;
if(pd%2==0){
if((pd/2)%2==0){
cout<<“3”;
}
else if((pd/2)%2!=0){
cout<<“2”;
}
}
else
std::cout << “1” << std::endl;
}
else if(y<x){
pd=y-x;
if(pd%2==0){
cout<<“1”;
}
else
std::cout << “2” << std::endl;
}

``````    t--;
}
return 0;
``````

}

What is wrong in this code ?

am javaScript developer. jest today opened CodeChef . How to Start it. and Where to find solutions in JS code. plz help me.

1 Like

Hi, anyone please tell me why did we use the difference between the X and Y. Because I am not to get this question like this my first question here.

1 Like

bro i am geting EOF error, even though i am using the editorial code. how to correct it

why i am getting EOF error with this solution, even i used the same code.

You can visit the problem and go to “all submissions” , then select you language and search.

for _ in range(int(input())):
x,y = input().split()
X = int(x)
Y = int(y)
dif = Y-X
rounds = 0
if dif>0 and dif%2==0:
if dif%4 != 0:
rounds =3
else:
rounds = 2
elif dif>0 and dif%2 != 0:
rounds = 1
elif dif<0 and dif%2 == 0:
rounds = 1
elif dif<0 and dif%2 != 0:
rounds = 2
else:
rounds = 0
print(rounds)
this code of mine works fine but after submitting it says that it is wrong ans.
please tell me any thing wrong with my code

@star_in if diff%4!=0 then rounds will be 2 because then we can find an odd number resulting in that difference else rounds will be 3.

Can anybody please explain this line…
#define zapp ios::sync_with_stdio(false);cin.tie(0)

since you can’t change the values of the ‘a’ and ‘b’, lets say, to make dif = 4 you have to take a = 3 and b =2
then a+a-b = 4 it means that we have to add the value of ‘a’ two time in X and value of ‘b’ one time.
So now the rounds will be 3, not 2.

In ps there is a term " in order to clean" so how can even x>y,
that means if x=4 and y=0 , so you are making things dirty to achieve the level of y

[quote=“aman1108, post:1, topic:80731”]

``````T=int(input())
for _ in range(T):
X,Y=map(int,input().split())
diff=abs(X-Y)
if(X>Y):
if (diff%2==0):
ans=1
else:
ans=2

elif (X<Y):
if (diff%2!=0):
ans=1

elif (diff%4==0):
ans=3

else:
ans=2

else:
ans=0

print(ans)

i use the same solution as above, still EOF error``````
1 Like

bro why it does it show EOF ERROR
when give
x = int(input())
whenever i try to give input like this

1 Like

Bro i copy pasted your code and after submitting, i got AC.
How are you getting EOF error?

In python, when you take input like this:

``````x = int(input())
y = int(input())
``````

Compiler will not take both values on a single line.
x will be taken as input on first line.
y will be taken as input on second line.

End of File(EOF) error is occurring because Codechef online judge is expecting that your code will take input on the same line.
Understood?

How are we not getting EOF error while taking input like this-

X,Y=map(int,input().split())

split() function is used to take space seperated values as input in a single line.In other words,split() will not return EOF if you take two(or more) space seperated values because it does not end if a white space is found.

map function is used to typecast the input from string data type to integer data type.

#include<stdio.h>

int main()
{
int t;
scanf("%d",&t);
while(t–)
{
int x,y;
scanf("%d",&x);
scanf("%d",&y);

``````	if(x>y)
{
if((x-y)%2==0)
printf("%d\n",1);
else
printf("%d\n",2);
}
if(y>x)
{
if((y-x)%4==0)
printf("%d\n",3);
else if((y-x)%2==0)
printf("%d\n",2);
else
printf("%d\n",1);
}

}

return 0;
``````

}

why this is not working