Friday, September 5, 2014

ChooseTheBestOne


Problem

Idea : Given a circle of people each having a t-shirt numbered from 1 to N . You have to find out the person with which t-shirt remain alive after playing  the discussed game in problem .

In this problem , we have to find out one , out of N . So , N-1 turn needed to eliminate N-1 people . In each turn t , people having t^3 called by shiny eliminate . After one elimination , we starts from the next person who was the next person of immediately eliminated . So , we need to start from the position . Each turn calling starts from 1 . So a person who is t^3 far from the current position will eliminate . So for every turn , we can find out the eliminated position by the formula :

                                E_Position = Current_position+t^3-1

The peoples are in circle and the counting may overlap . So , the formula will be :
                               
                                E_Position = ( Current_position+t^3-1 ) % Number_of_remaining_people .

My Solution

No comments:

Post a Comment