中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-15 13:32
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS批处理 & 脚本技术(批处理室) » [Discussion][Exploration] Using batch processing to make interesting math problems
Printable Version  38,436 / 139
Floor1 zouzhxi Posted 2006-11-12 08:20
中级用户 Posts 177 Credits 430 From 广东深圳
1. Find narcissistic numbers. (A narcissistic number is a number where the sum of the cubes of its digits equals the number itself. For example, 153 = 1*1*1 + 5*5*5 + 3*3*3)
Solution: 4F

2. There are four numbers. When any three numbers are added together, the resulting sums are 84, 88, 99, 110 respectively. Find these four numbers.
Solution: 11F、

3. Miss Zhao's age has the following characteristics:
①. Its cube is a four-digit number, and its fourth power is a six-digit number;
②. The four-digit number and the six-digit number exactly use all the ten digits from 0 to 9.
Ask, what number should this be?
Solution: 12F


4. Arranging the page numbers of a dictionary uses a total of 4889 digits. How many pages does this dictionary have in total? Answer: 1499
Solution: 15F

5. Ah Cong said that he saw a group of camels in the northwest this time. There are 23 humps and 60 feet in total. Ask how many single-humped and double-humped camels there are respectively?
Solution: 15F

6. There is a five-digit odd number. Replace all 2s in this five-digit odd number with 5s and all 5s with 2s, and keep other numbers unchanged to get a new five-digit number. If half of the new five-digit number is still 1 greater than the original five-digit number, what is the original five-digit number?
Solution: 23F、26F

7. The sum of five consecutive natural numbers can be divisible by 2, 3, 4, 5, 6 respectively. Find the smallest group of numbers that meet this condition.
Solution: 24F

8. I am a three-digit number. There is a digit "3", another digit is "1", and the other digit is unknown. If "3" is changed to "4" and "1" is changed to "3", then the original me will be 9 less than half of the assumed me. Do you know what the original one is?
Solution: 30F、

9. Farmer Jones said to his wife: "Hey, Maria, if we sell 75 chicks according to my method, then our chicken feed can last for 20 days. However, if we follow your suggestion and buy 100 more chicks, then the chicken feed will only last for 15 days."
"Ah, dear," she replied, "then how many chicks do we have now?"
Here is the problem. How many chicks do they have exactly?
Solution: 30F

10. Among all five-digit numbers, how many contain exactly two 3s?
Solution: 30F

11. Divide 17 into the sum of several natural numbers. Find the maximum product of these natural numbers.
Solution: 31F

12. Multiply natural numbers 2, 3... together. The last 6 digits of their product are exactly all 0s. What is the smallest possible last natural number?
Solution: 31F

13. The sum of the dividend, divisor and quotient is 181, and the quotient is 12. Find the dividend.
Solution: 31F

14. There are six boxes of goods in the store, weighing 15, 16, 18, 19, 20, 31 kilograms respectively. Two customers bought five of them. It is known that the weight of the goods bought by one customer is twice that of the other customer. Then, what is the weight of the remaining box of goods in the store?
Solution: 33F

15. A number leaves a remainder of 2 when divided by 3 and a remainder of 1 when divided by 5. What is the remainder when this number is divided by 15?
Solution: 35F

16.
①. p is a prime number, and p×p + 1 is also a prime number. Find 2006×p. Solution: None
②. What is the remainder when the product of 2006 2s is divided by 7? Solution: 40F

17. It is said that in a holy temple in India, there is a brass plate with three gem needles inserted on it. On the first gem needle, from bottom to top, there are 64 gold plates with holes in the center, getting smaller from bottom to top. The monks in the holy temple move the gold plates according to the following rules: only one plate can be moved each time, and the small plate must always be placed on the large plate. It was rumored at that time that when all 64 gold plates were moved to another gem needle, the world would be destroyed in a thunderclap. How many times does it take to move 64 gold plates to another gem needle? This is a very large number!
Answer: 18446744073709551615
Solution: 42F

18. There are ten banknotes with denominations of 1 cent, 2 cents, 5 cents, 1 jiao, 2 jiao, 5 jiao, 1 yuan, 2 yuan, 5 yuan, 10 yuan respectively. How many different denominations can be formed?
Solution: 43F

19. What is the number of even digits in the product of two ten-digit numbers 3333333333 and 9999999999? (Can it be done only with multiplication and subtraction?)
Solution: 65F

20. Three mutually meshing gears, namely gear A, gear B, and gear C. When gear A rotates 5 times, gear B rotates 7 times and gear C rotates 2 times. What should be the minimum number of teeth for each of these three gears respectively?
Solution: 66F

21. There are two basins of water, one cold and one hot. There is a thermometer in the cold water basin. Use a small cup to take a cup of hot water and pour it into the cold water. It is found that the temperature rises by 5 degrees. Then pour another cup of hot water in, and it rises by 3 degrees again. Ask, if you pour another cup in, how many degrees will it rise again? (This question is provided by NaturalJ0)
Solution: 76F

22. Find Pythagorean triples
Solution: 8F、9F

#23?
Weighing beads =
There are 243 beads that look exactly the same in appearance. One of them is a little heavier. With a balance without weights, what is the minimum number of weighings needed to find this bead?

#24?
The frog sitting in the well looking at the sky =
The frog sitting in the well one day suddenly got the whim to go out and see the world. The well is nine feet deep. The frog can only jump three feet high at a time. How many jumps does the frog need to make to jump out of the well?

#25?
How many chickens and dogs are there =
There are seventy-nine chicks and dogs. There are two hundred feet on the ground. Think about it and calculate, how many chickens are there? How many dogs are there?

#26?
How many big and small monks are there respectively =
This is an ancient arithmetic problem: One hundred monks and one hundred rice cakes. Each big monk eats four rice cakes, and four small monks eat one rice cake. How many big and small monks are there respectively?

#???
New question
http://www.cn-dos.net/forum/viewthread.php?tid=24951&pid=220052&page=9&sid=Y7sfAE#pid220052




——————————————Dividing line———————————————


***********************************
Version management log
***********************************
Operation: Essence of the topic
Executor: 3742668
Original reason: Thanks to zouzhxi and youxi01 and the friends downstairs for bringing such a wonderful post. The purpose of "learning together, progressing together" is vividly reflected in this post.
Explanation: Since there is no clear basis for essence currently, friends who have doubts about this operation can post a reply to point it out, or leave a message in the private message system.
***********************************


[ Last edited by zouzhxi on 2007-8-21 at 12:16 PM ]

Attachments
用批处理作趣味数学题(问题加代码).txt (19.94 KiB)
用批处理作趣味数学题(问题加代码).txt (20.16 KiB)
Floor2 不得不爱 Posted 2006-11-12 08:46
超级版主 Posts 2,044 Credits 5,310 From 四川南充
There are many numbers that conform to the Pythagorean theorem. Why do you say (that within 1,000,000,000,000 there is only one set like 5*5=3*3+4*4)? For example: 10*10=6*6+8*8, etc.

[ Last edited by 不得不爱 on 2006-11-11 at 08:59 PM ]
Floor3 zouzhxi Posted 2006-11-12 08:59
中级用户 Posts 177 Credits 430 From 广东深圳
Yes,
When running, I waited for half an hour,,,
The result is only this group, and the others are not equal...

For example: 6*6 ≠ 4*4 + 5*5
Floor4 lxmxn Posted 2006-11-12 09:45
版主 Posts 4,938 Credits 11,386

Among three-digit integers, only 153, 370, 371, and 407 have the characteristics of narcissistic numbers.

Please test this code:
Floor5 electronixtar Posted 2006-11-12 09:46
铂金会员 Posts 2,672 Credits 7,493
It turns out that batch processing algorithms are also so interesting
Floor6 namejm Posted 2006-11-12 11:49
荣誉版主 Posts 1,737 Credits 5,226 From 成都
lxmxn's code in 4F can be further streamlined. Replacing `for %%a` with a `for /l` counting loop can eliminate the need to list numbers.
Floor7 zh159 Posted 2006-11-12 12:12
金牌会员 Posts 1,467 Credits 3,687
4-digit numbers: 1634, 8208, 9474
5-digit numbers: 54748, 92727, 93084

^_^
Floor8 namejm Posted 2006-11-12 12:17
荣誉版主 Posts 1,737 Credits 5,226 From 成都
The algorithm for Pythagorean triples is as follows. Interestingly, when using the for /l counting loop, the speed of calculating narcissistic numbers is very fast, while the speed of calculating Pythagorean triples is very slow:
Floor9 youxi01 Posted 2006-11-13 00:56
高级用户 Posts 247 Credits 846 From 湖南==》广东
TO: Moderator of Floor 8: "The algorithm for Pythagorean triples is as follows. It's strange that when using a for /l counting loop, the speed of calculating narcissistic numbers is very fast, but the speed of calculating Pythagorean triples is very slow: Your amount of calculation is a thousand times that of the previous one, so of course the speed is much slower. You can make a slight modification to the code, which can not only eliminate duplicate terms (such as 3 4 5 and 4 3 5) but also greatly improve the running efficiency:



[ Last edited by youxi01 on 2006-11-16 at 11:41 PM ]
Floor10 namejm Posted 2006-11-13 01:11
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Hehe, not considering to eliminate duplicate results indeed can greatly increase the amount of computation.
Floor11 zouzhxi Posted 2006-11-13 02:26
中级用户 Posts 177 Credits 430 From 广东深圳
The Pythagorean triple I calculated is like this: 5*5 = 4*4 + 3*3, which is a group of consecutive numbers.



Another problem:
There are four numbers. When any three numbers are added together, the resulting sums are 84, 88, 99, 110 respectively. Find these four numbers?
My method is like this, write it out for you to see, don't laugh.

Do you have any simpler methods!!!!





Another problem:


Miss Zhao's age has the following characteristics:
1. Its cube is a four-digit number, and its fourth power is a six-digit number;
2. This four-digit number and six-digit number are exactly composed of the ten digits from 0 to 9.
Ask, what number should this be?


[ Last edited by zouzhxi on 2006-11-13 at 02:28 AM ]
Floor12 youxi01 Posted 2006-11-13 08:04
高级用户 Posts 247 Credits 846 From 湖南==》广东
This little girl is 18 years old. Making a humble show:

@echo off
setlocal enabledelayedexpansion
for /l %%i in (10 1 30) do (
::Clear variables
set flag=
for /l %%a in (0 1 9) do set %%a=
::Get cube and fourth power
set /a cube=%%i*%%i*%%i
set /a s=!cube!*%%i
if !cube! geq 1000 if !cube! lss 10000 (
if !s! geq 100000 if !s! lss 1000000 (
set num=!s!!cube!
call :test !num!
if not defined flag echo %%i !num!
)
)
)

pause>nul
:test
for /l %%a in (0 1 9) do (
set var=%1
::Assign the first digit of the parameter to var_; check whether the variable value !var_! has been defined as a variable.
set var_=!var:~%%a,1!
if defined !var_! set flag=1 & goto :eof
set !var_!=A
)
Floor13 lxmxn Posted 2006-11-13 09:57
版主 Posts 4,938 Credits 11,386
Wow, impressive~
Floor14 zouzhxi Posted 2006-11-13 10:06
中级用户 Posts 177 Credits 430 From 广东深圳
Another one,


A dictionary used 4889 digits in total for numbering the pages. How many pages does this dictionary have?

Answer: 1499.


Acong said he saw a group of camels in the northwest this time, with 23 humps and 60 feet. How many single-humped and double-humped camels are there respectively?


Gotta go, going to eat... Hehe... Come back on Monday...

[ Last edited by zouzhxi on 2006-11-13 at 10:10 AM ]
Floor15 youxi01 Posted 2006-11-13 12:15
高级用户 Posts 247 Credits 846 From 湖南==》广东
### Part One
@echo off
set /a t_num=0
setlocal enabledelayedexpansion

echo Checking data.....
for /l %%i in (1 1 4889) do (
if !t_num! lss 4889 (
if %%i lss 10 set /a t_num+=1
if %%i geq 10 if %%i lss 100 set /a t_num+=2
if %%i geq 100 if %%i lss 1000 set /a t_num+=3
if %%i geq 1000 set /a t_num+=4
) else set /a num=%%i-1 & goto :exit
)
:exit
echo The required number is: %num%
pause>nul

### Part Two
@echo off
set /a F_num=23
set /a J_num=60/4

setlocal enabledelayedexpansion
for /l %%i in (1 1 %J_num%) do (
set /a S_num=%%i
set /a B_num=%J_num%-%%i
set /a num=!S_num!+2*!B_num!
call :test !num! !S_num! !B_num!
)
pause>nul

:test
if %1 EQU %F_num% echo Possible combination: single-peak number=%2 double-peak number=%3
goto :eof
1 2 3 410  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023