82A - Double Cola - CodeForces Solution


implementation math *1100

Please click on ads to support us..

Python Code:

n=int(input())
k=5
while n>k:
    n -= k 
    k *= 2
k=k//5
if n%k==0:
    x=n//k 
else:
    x=n//k+1 
if x==1:
    print("Sheldon")
elif x==2:
    print("Leonard")
elif x==3:
    print("Penny")
elif x==4:
    print("Rajesh")
else:
    print("Howard")

C++ Code:

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define PB push_back
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define all(X) (X).begin(),(X).end()
#define Reverse(X) reverse(all(X))


#define maxe(A,n)      *max_element(A,A+n)
#define mine(A,n)      *min_element(A,A+n)
#define gcd(a,b)       __gcd(a,b)
#define lcm(a,b)       (a*(b/gcd(a,b)))
#define Unique(X) (X).erase(unique((X).begin(),(X).end()),(X).end())
const ll N=1.5*1e5+100;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;
    string s[]={"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"};
    ll Double=1;
    while(Double*5<n)
    {
      n-=Double*5;
      Double*=2;
    }
    n--;
    n/=Double;

    cout<<s[n]<<endl;
    
}


Comments

Submit
0 Comments
More Questions

231A - Team
479C - Exams
1030A - In Search of an Easy Problem
158A - Next Round
71A - Way Too Long Words
160A - Twins
1A - Theatre Square
1614B - Divan and a New Project
791A - Bear and Big Brother
1452A - Robot Program
344A - Magnets
96A - Football
702B - Powers of Two
1036A - Function Height
443A - Anton and Letters
1478B - Nezzar and Lucky Number
228A - Is your horseshoe on the other hoof
122A - Lucky Division
1611C - Polycarp Recovers the Permutation
432A - Choosing Teams
758A - Holiday Of Equality
1650C - Weight of the System of Nested Segments
1097A - Gennady and a Card Game
248A - Cupboards
1641A - Great Sequence
1537A - Arithmetic Array
1370A - Maximum GCD
149A - Business trip
34A - Reconnaissance 2
59A - Word