+ 10

A certain number X wants to know who will be it's dancing partner. Please help X.

All numbers in numberLand are standing in a circle for a dancing ceremony. Every number needs a dancing partner. Dancing partner of any number is the number which is standing radially opposite to it in the circle. The numbers are from 0(zero) to N-1. A certain number X wants to know who will be it's dancing partner. Please help X. Input : Two positive integers denoting the value of N and X. Sample Input : 8 2 Output : Print the number radially opposite to X in a circle of numbers. Sample Output : 6

1st Mar 2021, 10:44 AM
Dheerendra Kushwaha
Dheerendra Kushwaha - avatar
3 Antworten
+ 6
Where is your attempt ?
1st Mar 2021, 10:46 AM
TOLUENE
TOLUENE - avatar
+ 3
Number radially opposite to a number would be at same distance from both sides of the given number in case of even number of numbers. You can find that number by adding half of the total numbers to the given number: Dancing partner = (x + n/2)%n
1st Mar 2021, 11:02 AM
Temporary