Domanda

I want to make a C program which can solve the below given maths problem, but i'm not able to do it. I would highly appreciate if someone who can do it? A farmer has 81 cows numbered 1 to 81. no 1 cow gives 1kg milk ... no 2 gives 2 kg...... no 81 gives 81 kg per day. farmer has 9 sons. now he wants to distribute his cows among his sons such a way that every son take 9 cows & total quantity of milk will be same. how can he distribute?

È stato utile?

Soluzione

Not much math involved. More like, manipulation of collections.

Divide 81 cows into 9 lots of increasing size.

[ 1,  2,  3,  4,  5,  6,  7,  8,  9]
[10, 11, 12, 13, 14, 15, 16, 17, 18]
[19, 20, 21, 22, 23, 24, 25, 26, 27]
[28, 29, 30, 31, 32, 33, 34, 35, 36]
[37, 38, 39, 40, 41, 42, 43, 44, 45]
[46, 47, 48, 49, 50, 51, 52, 53, 54]
[55, 56, 57, 58, 59, 60, 61, 62, 63]
[64, 65, 66, 67, 68, 69, 70, 71, 72]
[73, 74, 75, 76, 77, 78, 79, 80, 81]

Left-shift the contents of each lot by one more than the previous one.

[ 1,  2,  3,  4,  5,  6,  7,  8,  9]
[11, 12, 13, 14, 15, 16, 17, 18, 10]
[21, 22, 23, 24, 25, 26, 27, 19, 20]
[31, 32, 33, 34, 35, 36, 28, 29, 30]
[41, 42, 43, 44, 45, 37, 38, 39, 40]
[51, 52, 53, 54, 46, 47, 48, 49, 50]
[61, 62, 63, 55, 56, 57, 58, 59, 60]
[71, 72, 64, 65, 66, 67, 68, 69, 70]
[81, 73, 74, 75, 76, 77, 78, 79, 80]

Each son chooses a column and takes all of those cows.

son #1 gets [ 1, 11, 21, 31, 41, 51, 61, 71, 81], for a total of 369.
son #2 gets [ 2, 12, 22, 32, 42, 52, 62, 72, 73], for a total of 369.
son #3 gets [ 3, 13, 23, 33, 43, 53, 63, 64, 74], for a total of 369.
son #4 gets [ 4, 14, 24, 34, 44, 54, 55, 65, 75], for a total of 369.
son #5 gets [ 5, 15, 25, 35, 45, 46, 56, 66, 76], for a total of 369.
son #6 gets [ 6, 16, 26, 36, 37, 47, 57, 67, 77], for a total of 369.
son #7 gets [ 7, 17, 27, 28, 38, 48, 58, 68, 78], for a total of 369.
son #8 gets [ 8, 18, 19, 29, 39, 49, 59, 69, 79], for a total of 369.
son #9 gets [ 9, 10, 20, 30, 40, 50, 60, 70, 80], for a total of 369.

This method appears to work for any number of sons, not just 9.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top