我怎么......太棘手了 [英] How do i...it is too tricky

查看:113
本文介绍了我怎么......太棘手了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拉姆和巧克力



拉姆是一名男生。他的好朋友从1到n。让它由数组A表示。具有更高数组索引的朋友更接近Ram。今天是他的生日,因此他希望以A [i + 1] = A [i] +3的方式分发他的生日巧克力。现在他的每个朋友都有n个从1到n编号的盒子,他的母亲用随机数量的巧克力装满了他们,然而Ram已经下定决心以上述方式分发巧克力。他想知道是否有可能在盒子里重新安排巧克力以获得他喜欢的分配模式。



我尝试了什么:



这个问题太棘手了回答,所以如果有人给出上述问题的答案....

解决方案

好好想想。



盒子里的巧克力数量是随机设置的



公羊队需要一个特定的发行版



如果有任何情况下盒子不符合分布,那么答案是不,他不能。如果所有的盒子都与分配完全对齐那么是的,他可以



现在:



如何你测试所有的盒子都可以对齐f(n-1)= f(n)+3吗?



你能想出几个例子吗?按照分布排列的数字数组?



您对这些数字顺序的注意事项是什么?



是否可以比较任何两个数字并确定它们是否符合分布?



查看这些问题。探索答案。你会看到问题是什么。



正如理查德所说,这个论坛不适合这类问题。您的老师会要求您从问题中学习特定内容。他们将能够比以往更直接地指导你。


 A [1] = a 
A [2] = A [1] + 3 = a + 3
A [3] = A [2] + 3 = a + 6
..
A [n] = A [n-1] + 3 = a +(n-1)* 3



总和是

 S = n * a + 3 + 6 + .. +(n-1)* 3 
S = n * a + 3 * [1 + 2 + .. +(n-1)]
S = n * a + 3 * n *(n-1)/ 2



因此

 a = [S  -  3 * n * (n-1)/ 2] / n 





计算 a ,如果它是整数然后分布是可行的。


引用:

这个问题太难理解了



第一步是用一张纸和一支铅笔手工解决。这就是你如何建立一个解决问题的算法/程序。

第一次试用失败是正常的。您通过反复试验了解并找到算法。 试用和错误是一种有效的学习方式。

请注意,部分答案表明您接近答案。

一旦有了解决方法问题,你必须翻译代码,这是你的算法。



我们不做你的HomeWork。

HomeWork未设置为在乞求其他人做你的工作时测试你的技能,它会让你思考并帮助你的老师检查你对你所学课程的理解以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。



作为程序员,您的工作是创建算法解决特定问题,你不能依赖别人永远为你做,所以有一段时间你必须学会​​如何。而且越快越好。

当你要求解决方案时,就像试图通过培训其他人来学习开车一样。

创建算法基本上是找到数学并做出必要的调整以适应你的实际问题。



发展的概念就像这个词所暗示的那样:系统地使用科学和满足特定目标或要求的技术知识。 BusinessDictionary.com [ ^ ]

这与有一个不一样快速谷歌并放弃,如果我找不到正确的代码。


Ram and Chocolates

Ram is a school boy. He has n good friends numbered from 1 to n. Let this be denoted by an Array A. The friend with higher array index is closer to Ram. It's his birthday today and hence he wants to distribute his birthday chocolates in a way such that A[i+1]=A[i]+3. Now he had n boxes numbered from 1 to n for each of his friend and his mother had filled them with some random number of chocolates, However Ram has made up his mind to distribute the the chocolates in the way described above. He wants to know if it is possible to re-arrange the chocolates in the boxes to have a distribution pattern he likes.

What I have tried:

well the question was too tricky to answer , so if any give out the answer for the question stated above....

解决方案

Well think about it.

The number of chocolates in the boxes is set at random

Rams wants a particular distribution

If there is any case where a box does not fit the distribution then the answer is "no, he can't". If all boxes align perfectly with the distribute then "yes, he can"

Now:

How do you test that all boxes can align to f(n-1) = f(n)+3 ?

Can you come up with a couple of examples of an array of numbers that follow the distribution?

What do you notice about that array of numbers in order?

Is it possible to compare any two numbers and decide that they do or do not fit the distribution?

Look into these questions. Explore the answers. You'll see what the question is getting at.

As Richard mentioned, this forum isn't suited for these kind of questions. Your teacher will want you to learn something specific from the question. They will be able to guide you more directly to that specific thing than we ever could.


A[1] = a
A[2] = A[1] + 3 = a + 3
A[3] = A[2] + 3 = a + 6
..
A[n] = A[n-1] + 3 = a + (n-1) * 3


The sum is

S = n * a + 3 + 6 + .. + (n-1) * 3 
S = n * a + 3 * [1 + 2 + .. + (n-1)] 
S = n * a + 3 * n * (n-1) / 2


hence

a = [S - 3 * n * (n-1) / 2] / n



Compute a, if it is integer then the distrubution is feasible.


Quote:

well the question was too tricky to answer


The first step is to solve by hand with a sheet of paper and a pencil. This is how you build an algorithm/procedure that solve the problem.
Failing on first trial is normal. You learn and find the algorithm by "trial and error". "Trial and Error" is an efficient way of learning.
Note that partial answer is an indication that you are close to the answer.
Once you have a method to solve the problem, you have to translate code, this is your algorithm.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.

The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".


这篇关于我怎么......太棘手了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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