hdu 3354 Probability One

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 n 0.
Then:
1. Ask your friend to compute n 1  = 3 * n 0  and to tell you if n1 is even or odd.
2. If n 1  is even, ask your friend to compute n 2  = n 1/2. If, otherwise, n 1  was odd then let your friend compute n 2  = (n 1  + 1)/2.
3. Now ask your friend to calculate n 3  = 3 * n 2.
4. Ask your friend to tell tell you the result of n 4  = n 3/9. (n 4  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 n 0  = 2 * n 4  if n 1  was even, or n 0  = 2 * n 4  + 1 otherwise.
Here’s an example that you can follow: If n 0  = 37, then n 1  = 111 which is odd. Now we can calculate n 2  = 56, n 3= 168, and n 4  = 18, which is what your friend will tell you. Doing the calculation 2 × n 4  + 1 = 37 reveals n 0.
 

 

Input
Your program will be tested on one or more test cases. Each test case is made of a single positive number (0 < n 0  < 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 
 
 1 //0MS    228K    366 B    G++
 2 /*
 3 
 4     题意:
 5         题目看似很难.其实是水题.直接按它的过程计算一遍即可得出解 
 6  
 7 */
 8 #include<stdio.h>
 9 int main(void)
10 {
11     int n;
12     int k=1;
13     while(scanf("%d",&n),n)
14     {
15         int odd=0;
16         n*=3;
17         if(n%2){
18             odd=1;
19             n=(n+1)/2;
20         }else n/=2;
21         n*=3;
22         n/=9;
23         if(odd) printf("%d. odd %d\n",k++,n);
24         else printf("%d. even %d\n",k++,n);
25     }
26     return 0;
27 } 

 

转载于:https://www.cnblogs.com/GO-NO-1/p/3439814.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值