ACM--吃罐头
来源:互联网 发布:eregi() 网页源码 编辑:程序博客网 时间:2024/06/11 17:45
Description
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.
Input
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.
Output
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.
Sample Input
Input
1
Output
Sheldon
Input
6
Output
Sheldon
Input
1802
Output
Penny
#include<stdio.h>void main(){ int count=0; int n; int k=1; int flag; scanf("%d",&n); //printf("%d",n); while(count<n) { for(int i=1;i<=5;i++) { count+=k; flag=i; //printf("%d",flag); if(count>=n) { if(flag==1) { printf("Sheldon\n"); return; } else if(flag==2) { printf("Leonard\n"); return; } else if(flag==3) { printf("Penny\n"); return; } else if(flag==4) { printf("Rajesh\n"); return; } else { printf("Howard\n"); return; } } } k*=2;
}}
- ACM--吃罐头
- ACM入门--吃糖果
- [ACM]吃糖果
- ACM-水题 吃糖果
- HDU ACM 1205 吃糖果
- 2015年ACM:吃糖果
- ACM-猴子吃桃问题
- 杭电ACM吃糖果问题
- 杭电ACM 1205 吃糖果
- 杭电ACM吃糖果问题
- ACM-动态规划5-吃糖果
- 杭电acm 1205 吃糖果
- 智力题目-02找罐头
- 生命是罐头,胆量是开罐器
- 【智力题】找出那只罐头
- ACM-数论之吃糖果——hdu1205
- [ACM] hdu 1205 吃糖果(鸽巢原理)
- 猴子吃桃问题 南阳理工ACM 324
- 杂谈: flash player 11.7 意义何在?
- Sqlplus导出excel文件
- javaWeb -- XML详细介绍
- 使用SQLPLUS生成HTML报表
- eclipse文件比较
- ACM--吃罐头
- [流媒体]jrtplib—VS2010下RTP开源协议库JRTPLIB3.9.1编译
- 关于cocos2d-x几种画图方法的用法与思考
- eclipse列编辑模式
- JSP简介
- [流媒体]Android 实时视频采集/编码/传输/解码/播放—方案调研(初)
- eclipse提取公共代码到私有的公共方法
- FlashPlayer 后缀的各种意思SA AX
- 利用rsync同步文件