思路:寻找规律,利用递归进行求解。(n-4)/2可以通过十个数进行发现。
#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";
}
}