查找1个字符的所有可能组合(是.请阅读问题) [英] Finding all possible combinations of 1 character (Yes. Read the question)

查看:133
本文介绍了查找1个字符的所有可能组合(是.请阅读问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我参加了针对高中生的南非计算机奥林匹克竞赛.我发现它相对容易.除了一个特定的问题外,这并不是什么挑战.该问题提出了一种外语,该外语仅使用一个字符写为%".可以在以下位置查看完整的问题:http://www.olympiad.org.za/docs/R2Qs_BW_2010.pdf(问题5:消息)

这个问题使我感到困惑.我绝对不知道如何解决这个难题.

顺便说一句,这必须用Java或Python完成.

谢谢,

Genius

I entered the South African Computer Olympiad for high school students. I found it relatively easy. It was not much of a challenge, with the exception of one particular question. The question proposes an alien language, which uses only one character to write with, ''%''. The full problem can be seen at: http://www.olympiad.org.za/docs/R2Qs_BW_2010.pdf (Question 5: Messages)

This question baffled me. I have absolutely no idea whatsoever how to solve this puzzle.

BTW, this had to be done in either Java or Python.

Thanks,

Genius

推荐答案

正在寻找的问题可以像这样重新表达:
我们可以用几种不同的方法来划分一堆豆子?所谓的不同,是指所得桩的大小不尽相同.例如,
1 => 1
2 => 2 1 1
3 => 3,2 1,1 1 1
4 => 4,3 1,2 2,2 1 1,1 1 1 1
5 => 5,4 1,3 2,3 1 1,2 1 1 1,1 1 1 1 1
因此(翻译回Unarus语言)有
1封1封信的邮件
2条2个字母的消息
3条3个字母的消息
5条4个字母的消息
5个字母的6条消息
...等等.

关于从这里出发的建议:
1.考虑以下问题:
如果我们有 n 个bean的解决方案,我们如何找到 n + 1 的解决方案?
2.想一想:
当第四个字母周围的其他字母仅增加一个时,为什么还要添加两个解决方案?在将它们写出来之前,您希望六个字母有多少个?

我的直觉是,攻击建议#2会比#1更好.
祝你好运,尽情享受吧!
彼得
What the question is looking for can be re-expressed like this:
How many different ways can we divide a pile of beans? By different, we mean that the sizes of the resulting piles are not all the same. For example,
1 => 1
2 => 2, 1 1
3 => 3, 2 1, 1 1 1
4 => 4, 3 1, 2 2, 2 1 1, 1 1 1 1
5 => 5, 4 1, 3 2, 3 1 1, 2 1 1 1, 1 1 1 1 1
so (translating back into Unarus-language) there are
1 message of 1 letter
2 messages of 2 letters
3 messages of 3 letters
5 messages of 4 letters
6 messages of 5 letters
... and so on.

Suggestions about where to go from here:
1. Think about the following problem:
If we have the solution for n beans, how do we find the solution for n+1?
2. Think about this one:
Why does the fourth letter add two solutions when the others around it only add one? Before you write them out, how many would you expect for six letters?

My gut feel is that attacking suggestion #2 will lead to a better answer than #1.
Good luck, and ENJOY!
Peter


好问题,但我将留给他人解决:)
Good Question, but I shall leave it to others to solve :)


这篇关于查找1个字符的所有可能组合(是.请阅读问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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