82A Codeforces - Double Cola



82A Codeforces - Double Cola




Solution in c++


#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli n,t,sol,l;
vector<lli> all;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    for(int i=0;i<29;i++)all.push_back(5*pow(2,i));
    cin>>n;
    for(int i=0;i<29;i++)if(t+all[i]<n)t+=all[i],l++;
    lli o=pow(2,l);
    sol=(n-t)/pow(2,l);
    if( (n-t)% o!=0 )sol++;
    if(sol==1)cout<<"Sheldon";
    else if(sol==2)cout<<"Leonard";
    else if(sol==3)cout<<"Penny";
    else if(sol==4)cout<<"Rajesh";
    else if(sol==5)cout<<"Howard";
    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق