查找农场的腿数...... [英] Find number of legs on a farm...

查看:80
本文介绍了查找农场的腿数......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我有一项任务需要完成。我试图找出最好的

方式,用C ++来确定以下内容。有这个农场有猪

和鸡。只有猪和鸡的腿看起来完全相同,所以对于一个矮个子来确定有多少可能的猪以及许多可能的鸡怎么样,他们所能做的就是是计算

两的总腿数。


- 鸡似乎总是在3个组中运行$

- 猪好像总是聚在一起成群结队的8个孩子 - 猪总是有4条腿和小鸡总是有2条腿


我需要弄清楚总数是多少可能性(比如有
300种不同的可能性)并列出用户的可能性

请求(8头猪和3头鸡或600头猪和89头鸡等)。 br />

我不能使用数组或精确的中文余数定理(我可以使用

变体)。


这是一项任务,所以我不需要完整的答案。我在计算步骤中遇到的麻烦最多。


我已经确定会有2个计算函数,
虽然如果可以通过1个计算功能完成,那就太棒了。


如果你能帮助我,我会很感激!!!!!

解决方案

* Petrakid:


>

这是一项任务,所以我不需要完整的答案。



好​​。


Hth。,


- Alf


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕东西?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?


Petrakid写道:


嘿,我有一项任务需要完成。我试图找出最好的

方式,用C ++来确定以下内容。有这个农场有猪

和鸡。只有猪和鸡的腿看起来完全相同,所以对于一个矮个子确定有多少可能的猪和

多少可能的鸡,他们只能做计算总腿数

两个。


- 鸡似乎总是在3个组中运行$

- 猪好像总是聚在一起成群结队的8个孩子 - 猪总是有4条腿和小鸡总是有2条腿


我需要弄清楚总数是多少可能性(比如那里

有300种不同的可能性)并列出

用户请求的可能性(8头猪和3头鸡或600头猪和89头鸡等)。 br />

我不能使用数组或精确的中文余数定理(我可以使用

a变体)。


这是一项任务,所以我不需要完整的答案。我在计算步骤中遇到的麻烦很多。


我已经确定会有2个计算函数,
虽然如果可以通过1个计算功能完成,那就太棒了。


如果你能帮助我,我会很感激!!!!!



好​​吧,你有腿数,对吧?你需要搞清楚

所有解决方案

x * 3 * 2 + y * 8 * 4 = N


其中N是腿数,x和y分别是

组鸡和猪的数量。然后你将

''x''乘以3得到鸡的数量。而且我的乘数增加了8个你得到猪的数量。


V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复,请不要问


Petrakid发布:


有这个农场有猪

和鸡。



很酷,我喜欢猪和鸡。


只有猪的腿和鸡看起来完全相同




极端含糊不清的声明。


所以对于一个矮个子来确定可能有多少只猪以及许多可能的鸡怎么样,他们所能做的只是计算

两的总腿数。


- 鸡似乎总是在3
的组中运行



这是每组6条腿然后没有?


- Pigs似乎总是聚集在一起,每组8



'每组32条腿,没有?


- 猪总是有4条腿和鸡只有2条腿



OH我的上帝你是否很严重?


如果哟可以帮助我,我会很感激!!!!!



如果有192条腿,则可能有:


(1)三十二组鸡,零猪群。

(2)六组猪,零组鸡。


这是_I_将如何实现:


从原始数字开始,如92腿。


(1)从中减去32.

(2)看看结果%6是否为假。

(3)如果是,你有一个组合。

(4)重复直到结果< 32

然后用6来做:


(1)从中减去6。

(2)看看结果%32是否为假。

(3)如果是,你有一个组合。

(4)重复直到结果< 6.


无论如何都是这样的。


-


Frederick Gotham


Hey, I have a task to complete. I am trying to figure out the best
way, in C++ to determine the following. There is this farm with pigs
and chickens. Only the legs of the pigs and chickens look exactly the
same, so for a short person to determine how many possible pigs and how
many possible chickens, all they can do is count the total legs of the
two.

- Chickens seem to always run around in groups of 3
- Pigs seem to always clump together in groups of 8
- pigs ALWAYS have 4 legs and chickens ALWAYS have 2 legs

I need to figure out the total number of possibilities ( like there are
300 different possibilities) AND list the possibilities at the users
request (8 pigs and 3 chicken or 600 pigs and 89 chickens, etc).

I CANNOT use arrays or the exact chinese remainder theorem (i can use a
variation of it).

this is an assignment, so I don''t need the complete answer. I''m having
the most trouble with the calculation steps.

I''ve already determined that there will be 2 calculation functions,
though if it can be done with 1 calculation function, that''s great.

If yo could help me out, I would appreciate it!!!!!

解决方案

* Petrakid:

>
this is an assignment, so I don''t need the complete answer.

Good.

Hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Petrakid wrote:

Hey, I have a task to complete. I am trying to figure out the best
way, in C++ to determine the following. There is this farm with pigs
and chickens. Only the legs of the pigs and chickens look exactly the
same, so for a short person to determine how many possible pigs and
how many possible chickens, all they can do is count the total legs
of the two.

- Chickens seem to always run around in groups of 3
- Pigs seem to always clump together in groups of 8
- pigs ALWAYS have 4 legs and chickens ALWAYS have 2 legs

I need to figure out the total number of possibilities ( like there
are 300 different possibilities) AND list the possibilities at the
users request (8 pigs and 3 chicken or 600 pigs and 89 chickens, etc).

I CANNOT use arrays or the exact chinese remainder theorem (i can use
a variation of it).

this is an assignment, so I don''t need the complete answer. I''m
having the most trouble with the calculation steps.

I''ve already determined that there will be 2 calculation functions,
though if it can be done with 1 calculation function, that''s great.

If yo could help me out, I would appreciate it!!!!!

Well, you have the number of legs, right? You need to figure out
all solutions of

x*3*2 + y*8*4 = N

where ''N'' is the number of legs and ''x'' and ''y'' is the number of
groups of chickens and pigs, respectively. Then you multiply the
''x'' by 3 and you get the number of chickens. And my multiplying
''y'' by 8 you get the number of pigs.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


Petrakid posted:

There is this farm with pigs
and chickens.


Cool, I like pigs and chickens.

Only the legs of the pigs and chickens look exactly the
same,


Extrememly ambiguous statment.

so for a short person to determine how many possible pigs and how
many possible chickens, all they can do is count the total legs of the
two.

- Chickens seem to always run around in groups of 3


That''s 6 legs per group then no?

- Pigs seem to always clump together in groups of 8


That''s 32 legs per group, no?

- pigs ALWAYS have 4 legs and chickens ALWAYS have 2 legs


OH MY GOD ARE YOU SERIOUS?

If yo could help me out, I would appreciate it!!!!!


If there are 192 legs, then there could be:

(1) Thirty-two groups of chickens, zero groups of pigs.
(2) Six groups of pigs, zero groups of chickens.

Here''s how _I_ would go about it:

Start off with the original figure like "92 legs".

(1) Subtract 32 from it.
(2) See if the result % 6 is false.
(3) If so, you have a combination.
(4) Repeat until result < 32

Then do it with 6:

(1) Subtract 6 from it.
(2) See if the result % 32 is false.
(3) If so, you have a combination.
(4) Repeat until result < 6.

Something along those lines in anyway.

--

Frederick Gotham


这篇关于查找农场的腿数......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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