A. Double Cola Solution

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int r = 1;
    while (r * 5 < n)
    {
        n -= r * 5;
        r *= 2;
    }
    string names[] = {"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"};
    cout << names[(n - 1) / r] << endl;
    return 0;
}


No comments

Theme images by enot-poloskun. Powered by Blogger.