82A - Double Cola
来源:互联网 发布:阿里云 cdn 七牛 编辑:程序博客网 时间:2024/06/08 15:56
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.
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.
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.
1
Sheldon
6
Sheldon
1802
Penny
a = ["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"]n = gets.chomp.to_ix = 1until x*5>n n -= x*5 x *= 2endputs a[(n-1)/x]
- 82A - Double Cola
- 82A - Double Cola
- CodeForces 82A Double Cola
- CodeForces-82A-Double Cola
- CF 82A Double Cola
- Problem--82A--Codeforces--Double Cola
- A. Double Cola
- A. Double Cola
- Codeforces A. Double Cola 题解
- codeforces-82A-Double Cola( 等比数列 + 有意思的题目! )
- Yandex.Algorithm 2011 A. Double Cola
- Double Cola
- Codeforces Yandex.Algorithm 2011 Qualification 2 / 82A Double Cola (数学规律&模拟)
- Yandex.Algorithm 2011 Qualification 2 A. Double Cola
- Cola
- CodeForces 44B- A - Cola- 分类讨论
- 11150 - Cola
- Cola HDU1495
- Vs2010编译mp4v2-2.0.0
- libxml主要函数说明
- SVN感叹号
- webservice客户端handler的处理机制
- SimpleAdapter实现点击事件
- 82A - Double Cola
- BZOJ 1096 ZJOI 2007 仓库建设 斜率优化DP
- poi创建excel工作表表名为中文乱码
- QT 进程间通信之古老的方法(内存共享)
- 什么是中(工)频感应电炉炉衬料?
- Java的中间缓存变量机制与自增操作符
- 美国零售业向阿里巴巴电商抗议
- Tomcat7.0源码学习(一)之源码编译
- C#调用SAPI实现语音识别的两种方法