Acm hdu 3354 probability one (simple question)

Source: Internet
Author: User
Probability one

Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 301 accepted submission (s): 224

Problem descriptionnumber 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 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.

Inputyour 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 .)

Outputfor 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 input37
38
0

Sample output1. odd 18
2. Even 19

Source2009 anarc

Recommendlcy
 # Include  <  Stdio. h  >  
Int Main ()
{
Int N0;
Int Icase = 0 ;
While (Scanf ( " % D " , & N0), N0)
{
Icase ++ ;
Printf ( " % D. " , Icase );
If (N0 % 2 = 0 )
Printf ( " Even % d \ n " , N0 / 2 );
Else
Printf ( " Odd % d \ n " , (N0 - 1 ) / 2 );
}
Return 0 ;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.