Probability One

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 379    Accepted Submission(s): 293

Problem Description
Number guessing is a popular game between elementary-school kids. Teachers encourage pupils to play the game as it enhances their arithmetic skills, logical thinking, and following-up simple procedures. We think that, most probably, you too will master in few minutes. Here’s one example of how you too can play this game: Ask a friend to think of a number, let’s call it n0.
Then:
1. Ask your friend to compute n1 = 3 * n0 and to tell you if n1 is even or odd.
2. If n1 is even, ask your friend to compute n2 = n1/2. If, otherwise, n1 was odd then let your friend compute n2 = (n1 + 1)/2.
3. Now ask your friend to calculate n3 = 3 * n2.
4. Ask your friend to tell tell you the result of n4 = n3/9. (n4 is the quotient of the division operation. In computer lingo, ’/’ is the integer-division operator.)
5. Now you can simply reveal the original number by calculating n0 = 2 * n4 if n1 was even, or n0 = 2 * n4 + 1 otherwise.
Here’s an example that you can follow: If n0 = 37, then n1 = 111 which is odd. Now we can calculate n2 = 56, n3= 168, and n4 = 18, which is what your friend will tell you. Doing the calculation 2 × n4 + 1 = 37 reveals n0.
 
Input
Your program will be tested on one or more test cases. Each test case is made of a single positive number (0 < n0 < 1, 000, 000).
The last line of the input file has a single zero (which is not part of the test cases.)
 
Output
For each test case, print the following line:
k. B Q
Where k is the test case number (starting at one,) B is either ’even’ or ’odd’ (without the quotes) depending on your friend’s answer in step 1. Q is your friend’s answer to step 4.
Note: There is a blank space before B.
 
Sample Input
37
38
0
 
Sample Output
1. odd 18
2. even 19
 
Source
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  3351 3352 3353 3355 3356 
 
 //0MS    228K    366 B    G++
/* 题意:
题目看似很难.其实是水题.直接按它的过程计算一遍即可得出解 */
#include<stdio.h>
int main(void)
{
int n;
int k=;
while(scanf("%d",&n),n)
{
int odd=;
n*=;
if(n%){
odd=;
n=(n+)/;
}else n/=;
n*=;
n/=;
if(odd) printf("%d. odd %d\n",k++,n);
else printf("%d. even %d\n",k++,n);
}
return ;
}

hdu 3354 Probability One的更多相关文章

  1. HDU 2131 Probability

    http://acm.hdu.edu.cn/showproblem.php?pid=2131 Problem Description Mickey is interested in probabili ...

  2. HDU 4978 A simple probability problem

    A simple probability problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  3. HDU 6595 Everything Is Generated In Equal Probability (期望dp,线性推导)

    Everything Is Generated In Equal Probability \[ Time Limit: 1000 ms\quad Memory Limit: 131072 kB \] ...

  4. hdu多校第二场 1005 (hdu6595) Everything Is Generated In Equal Probability

    题意: 给定一个N,随机从[1,N]里产生一个n,然后随机产生一个n个数的全排列,求出n的逆序数对的数量,加到cnt里,然后随机地取出这个全排列中的一个非连续子序列(注意这个子序列可以是原序列),再求 ...

  5. hdu 2955 01背包

    http://acm.hdu.edu.cn/showproblem.php?pid=2955 如果认为:1-P是背包的容量,n是物品的个数,sum是所有物品的总价值,条件就是装入背包的物品的体积和不能 ...

  6. HDU 2955 Robberies 背包概率DP

    A - Robberies Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  7. HDU 4816 Bathysphere(数学)(2013 Asia Regional Changchun)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 Problem Description The Bathysphere is a spheric ...

  8. HDU 3076:ssworld VS DDD(概率DP)

    http://acm.split.hdu.edu.cn/showproblem.php?pid=3076 ssworld VS DDD Problem Description   One day, s ...

  9. HDU 3853:LOOPS(概率DP)

    http://acm.split.hdu.edu.cn/showproblem.php?pid=3853 LOOPS Problem Description   Akemi Homura is a M ...

随机推荐

  1. 谷歌angle库使用心得

    通过谷歌的angle库可以在项目中,调用opengl接口渲染时,选择调用directx或者webgl来渲染,避免机器没有安装opengl驱动启动异常的问题. 这个库的使用可以不修改原有使用opengl ...

  2. jQuery选择器与事件学习笔记

    层次选择器:  $("div li")获取div下的所有li元素(后代.子.子的子......)  $("div>li")获取div下的直接li子元素.  ...

  3. 泉五培训Day4

    T1 收果子 题目 [题目描述] 有一个果园,有n棵果树依次排成一排,其中已知第 i 棵果树上结了ai个果子.现在要按照果树编号顺序依次收果子,对于一个能装v个果树的果篮,收果子从第1棵果树开始,如果 ...

  4. 洛谷P2759 奇怪的函数(log 二分)

    题目描述 使得 x^xxx 达到或超过 n 位数字的最小正整数 x 是多少? 输入输出格式 输入格式: 一个正整数 n 输出格式: 使得 x^xxx 达到 n 位数字的最小正整数 x 输入输出样例 输 ...

  5. 基于mybatis设计简单OA系统问题3

    1.  问题:使用mybatis更新数据失败 描述:java.lang.NullPointerException 提交表单 com.duma.entity.User.updateUser - ==&g ...

  6. Struts2之基于配置的字段校验

    上一篇struts2之输入校验介绍了手动完成输入校验,也即依靠重写validate方法和validateXxx方法,指定请求某个方法时对传入的参数进行校验. 本篇介绍基于配置的字段校验.下面是登录的常 ...

  7. scapy--初识

    常用的包结构: (1)OSI 5层模型 OSI中的层 功能 TCP/IP协议族 应用层 文件传输,电子邮件,文件服务,虚拟终端 TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet 传 ...

  8. html5中的progress兼容ie,制作进度条样式

    html5新增的progress标签用处很大,它可以制作进度条,不用像以前那样用css来制作进度条! 一.progress使用方法 progress标签很好使用,他有两个属性,value和max,va ...

  9. linux poll用法

    相对于select来说,poll 也是在指定时间内论询一定数量的文件描述符,来测试其中是否有就绪的,不过,poll 提供了一个易用的方法,来实现 i/o 复用. 声明如下: #include < ...

  10. Git ---游离状态下的commit 分支切换与找回,commit之后无法找到历史记录

    commit之后无法找到历史记录 https://blog.csdn.net/zyb2017/article/details/78307688