CF 82A Double Cola

Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on. This process continues ad infinitum.

For example, Penny drinks the third can of cola and the queue will look like this: Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny.

Write a program that will print the name of a man who will drink the n-th can.

Note that in the very beginning the queue looks like that: Sheldon, Leonard, Penny, Rajesh, Howard. The first person is Sheldon.

Input

The input data consist of a single integer n (1 ≤ n ≤ 109).

It is guaranteed that the pretests check the spelling of all the five names, that is, that they contain all the five possible answers.

Output

Print the single line — the name of the person who drinks the n-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" (without the quotes). In that order precisely the friends are in the queue initially.

Examples
input
1
output
Sheldon
input
6
output
Sheldon
input
1802
output
Penny

题意:五个人, 每一个人喝完水后都会分裂成两个插入队尾,所以肯定是五个一模一    样的等比数列;所以只需要除以2倒推回1~5的状态就行;

AC代码:

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int get(int n)
{
    if(n <= 5) return n;
    else return get( (n-4)/2 );
}
int main()
{
    string re[] = { "", "Sheldon", "Leonard", "Penny", "Rajesh", "Howard"};
    int n;
    while(cin >> n)
    {
        cout << re[get(n)] << "\n";
    }
}


你可能感兴趣的:(CF 82A Double Cola)