[Partial Judge Problem]
Problem description:
We define a Josephus game as follows:
1. There are n people , numbered as 1 to n, in a circle and arranged in clockwise.
2. The person with ID = 1 is the killer at the beginning of the game.
3. If the number of survivor is even :
The killer will kill the person who is oppisite from himself .
The person next to the victim in clockwise direction will be the new killer.
Ex: If there are 4 people in the game , the 1st victim will be 3 .
4 will become the new killer.
1(killer) 1
4 2 -----> 4(killer) 2
3(victim)
4. If the number of survivor is odd :
The killer will kill the person next to himself in counter-clockwise direction.
The person next to the victim in counter-clockwise direction will be the new killer.
Ex:
1 1(killer)
4(killer) 2(victim) -----> 4
5. The winner is the one survive at the end of the game.
Judge language : C
Your task is to implement following functions :
Submit format:
#include <stdio.h>
#include <stdlib.h>
#include "function.h"//------------------------------------------
/*Other functions*/
//------------------------------------------
int solveJosephus(int n , Node* head){
/*your code here*/
}
Node* createList(int n , Node* head){
/*your code here*/
}
There are multiple lines in an input testcase .
Each line represents a Josephus game
Each line contains an integer indicates the number of people joining the josephus game.
The input format is determined by the judge code
You don't have to worry about it.
Show the winner of each josephus game.
The output format is determined by the judge code.
You don't have to worry about it .