theblackkazekage / firedemployees Goto Github PK
View Code? Open in Web Editor NEWMr. Alfred is the founder of FooLand Constructions. He always maintains a ‘Black list’ of potential employees which can be fired at any moment without any prior notice. This company has N employees (including Mr. Alfred), and each employee is assigned a rank (1 <= rank <= N) at the time of joining the company. Any person can have any rank from 1 to N. No two persons have the same rank. The company has a hierarchically organized management. Each employee has one immediate senior but can have any number of seniors. If a person A is the senior of B and B is senior of C, this implies that A is also a senior of C. Note that Mr. Alfred has no senior to him. Mr. Alfred has a strange and unfair way of evaluating an employee’s performance. Those employees the sum of whose rank and the number of his/her seniors is a prime number is put up on the ‘Black list’. You are required to find out the number of ‘Black listed’ employees. Note: The list won’t contain Mr. Alfred’s name as he is the founder of the company and the list is managed by him!