首页 > 其他分享 >北大ACM poj3994 Probability One

北大ACM poj3994 Probability One

时间:2023-08-21 17:06:46浏览次数:30  
标签:even Probability poj3994 ACM test n1 odd your friend


Probability One


Time Limit: 1000MS

 

Memory Limit: 65536K

Total Submissions: 938

 

Accepted: 660


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


Sample Input


37 38 0


Sample Output


1. odd 18 2. even 19


一道水得没法再水的题。

#include<stdio.h>
main()
{
	int i=0,n;
	while(scanf("%d",&n),n)
	{
		i++;
		printf("%d. %s %d\n",i,n%2?"odd":"even",n/2);
	}
}

标签:even,Probability,poj3994,ACM,test,n1,odd,your,friend
From: https://blog.51cto.com/u_10101161/7177241

相关文章

  • 北大ACM poj3750 小孩报数问题
    小孩报数问题TimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:7233 Accepted:3454Description有N个小孩围成一圈,给他们从1开始依次编号,现指定从第W个开始报数,报到第S个时,该小孩出列,然后从下一个小孩开始报数,仍是报到S个出列,如此重复下去,直到所有的小孩都......
  • 北大ACM poj1002 487-3279
    487-3279TimeLimit:2000MS MemoryLimit:65536KTotalSubmissions:191845 Accepted:33280DescriptionBusinessesliketohavememorabletelephonenumbers.Onewaytomakeatelephonenumbermemorableistohaveitspellamemorablewordorphrase.......
  • 北大ACM poj1661 Help Jimmy
    HelpJimmyTimeLimit:1000MS MemoryLimit:10000KTotalSubmissions:7380 Accepted:2333Description"HelpJimmy"是在下图所示的场景上完成的游戏。场景中包括多个长度和高度各不相同的平台。地面是最低的平台,高度为零,长度无限。Jimmy老鼠在时刻0从高......
  • 北大ACM poj1050 To the Max(C++)
    TotheMaxTimeLimit:1000MS MemoryLimit:10000KTotalSubmissions:32446 Accepted:16930DescriptionGivenatwo-dimensionalarrayofpositiveandnegativeintegers,asub-rectangleisanycontiguoussub-arrayofsize1*1orgreaterlocatedwithi......
  • 北大ACM poj2141 Message Decowding
    MessageDecowdingTimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:10326 Accepted:5672DescriptionThecowsarethrilledbecausethey'vejustlearnedaboutencryptingmessages.Theythinktheywillbeabletousesecretmessagestoplot......
  • 北大ACM poj2590
    /*找规律后发现增量是1,1,2,2,3,3,4,4,5,5......,可以发现它是个隔位曾1的自然序列步数:12345678910+1+1+2+2+3+3+4+4+5+501246912......
  • 北大ACM poj1636
    /*problem:poj1636如果s中的每个字母在t中都有则输出Yes(注意是Yes,不是YES)代码很简单,就不解释了*/#include<stdio.h>chars[100010],t[100010];intmain(){while(~scanf("%s%s",s,t)){inti=0,j;for(j=0......
  • ACM题目 英雄护美(递归)
    /*英雄护美英雄救美,可以理解;英雄护美,亦可理解。m(1<=m<=54)个英雄和美晚上行军,路过大峡谷,只能以纵队的方式前行。为确保美的绝对安全,纵队中每两个美之间必须至少有一个以上的英雄。如m为3时,有5种行军方式,分别为:美-英雄-美、美-英雄-英雄、英雄......
  • ACM题目:孔融分梨
    /*孔融分梨孔融让梨,人人称颂;孔融分梨,也不简单。孔融有M个同样的梨,要分给N个人。每个人手上有一个同样的盘子,孔融要将梨放入盘中,允许有的盘子空着不放,问共有多少种不同的分法?3,1,1和1,3,1和1,1,3是同一种分法。第一行是测试数据的数目t(0<......
  • ACM题目:英雄护美
    /*英雄护美英雄救美,可以理解;英雄护美,亦可理解。m(1<=m<=54)个英雄和美晚上行军,路过大峡谷,只能以纵队的方式前行。为确保美的绝对安全,纵队中每两个美之间必须至少有一个以上的英雄。如m为3时,有5种行军方式,分别为:美-英雄-美、美-英雄-英雄、英......