如何解决这个问题呢 [英] How to solve this problem

查看:102
本文介绍了如何解决这个问题呢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标记从1到N的牌。在每个回合中,我们销毁一些牌并继续直到只留下一张牌。如果剩下的卡数是奇数,保留最小数量的卡并随机销毁一半下雨的可用卡。如果数字是剩余的卡是偶数,随机销毁一半的可用卡。 Xth卡剩余的最后一张概率是多少?



我尝试过的事情:



如果输入是偶数,则答案是1 / n

There cards marked from 1 to N. In each turn, we destroy some cards and it goes on till only one card is left. If the number of cards left is odd, preserve the card with the smallest number and randomly destroy half of the raining available cards. If the number is cards left is even, randomly destroy half of the available cards. What is the probability that the Xth card is last one remaining?

What I have tried:

If the input is even, answer is 1/n

推荐答案

您可以通过考虑所涉及的问题来解决它。你开始有多少张牌?你每回合摧毁多少人?如果游戏结束时只留下一张牌,那么留下的牌数必须是奇数。



你的问题远非明确,但它仍然是你的工作解决它。
You solve it by thinking about the issues involved. How many cards do you start with? How many do you destroy in each turn? If the game ends with only one card left then the number of cards left has got to be odd.

Your question is far from clear, but it is still your job to solve it.


我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



所以坐下来遵守规则和卡片组(将1到13分配给数字套装)并自行应用。经过几次迭代后,你应该知道游戏是如何玩的,以及它是如何手动工作的。然后,这只是将其翻译成计算机可以理解的内容的情况。首先设置卡座,然后编写功能进行各种操作。

自己尝试一下,你可能会发现它并不像你想象的那么难!



如果您遇到特定问题,请询问相关问题,我们会尽力提供帮助。但是我们不会为你做这一切!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

So sit down with the rules and deck of cards (assign 1 to 13 to a suit for numbers) and apply them yourself. After a few iterations, you should have a good idea how the game is played, and how it works manually. Then it's just a case of translating that into something the computer can understand. Start by setting up the "deck", then write functions to do the various operations.
Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


你必须访问并学习C教程用于支持你的作业。



编写代码时,最好将所有任务分离到较小的操作并编写功能。最好使用每个步骤中创建的一些N数组。卡片可以是颜色和数字的结构。



从创建一些UML图表开始。你的老师会喜欢它 - ; - )
You must visit and Learn C tutorial for sovling your homeworks.

When you write your code you best begin with separating all tasks to smaller operations and write functions aroud them. At best you work with some arrays of N which are created in every step. A card may be a struct of color and digit.

Start with creating some UML diagrams. Your teacher will like it- ;-)


这篇关于如何解决这个问题呢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆