中国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-11-10 12:50
47,815 topics / 349,930 posts / today 0 new / 48,291 members
DOS批处理 & 脚本技术(批处理室) » [Discussion][Exploration] Using batch processing to make interesting math problems
Printable Version  40,603 / 139
Floor16 ccwan Posted 2006-11-13 21:08
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Not bad. Have research on algorithms.
Floor17 kennyfan Posted 2006-11-13 22:08
中级用户 Posts 112 Credits 259
Wow..In-depth...Learninging!!!
Floor18 zouzhxi Posted 2006-11-15 00:26
中级用户 Posts 177 Credits 430 From 广东深圳
To promote algorithm research, heh heh.


There is a five-digit odd number. Replace all 2s with 5s and all 5s with 2s in this five-digit odd number, while keeping other digits unchanged, to get a new five-digit number. If half of the new five-digit number is still 1 more than the original five-digit number, what is the original five-digit number?
Floor19 redtek Posted 2006-11-15 00:42
金牌会员 Posts 1,147 Credits 2,902
Haha... Interesting~ :)
Can start a batch processing and data structure algorithm special section~ :)
Floor20 zouzhxi Posted 2006-11-15 02:25
中级用户 Posts 177 Credits 430 From 广东深圳
The sum of five consecutive natural numbers can be divided by 2, 3, 4, 5, and 6 respectively. Find the smallest set of such numbers that meets the condition.
Floor21 Michale Posted 2006-11-15 03:56
初级用户 Posts 27 Credits 52 From ☆逍遥宫☆
Not bad~~After seeing so many treatments~~I think the several treatments upstairs are quite beautiful~~worthy of everyone's joint research~~Thank you all~~~
Floor22 namejm Posted 2006-11-15 06:36
荣誉版主 Posts 1,737 Credits 5,226 From 成都
It is suggested that zouzhxi concentrate all issues in the top in the format of serial number + content listed. Once solved, make a mark or instruction behind this serial number, so that everyone can see which interesting topics are in this post.
Floor23 youxi01 Posted 2006-11-15 07:24
高级用户 Posts 247 Credits 846 From 湖南==》广东
Finally back again!

Reply to post 18, the answer is: 29995.

The test code given:



Explanation: This program was tested and passed under XP pro sp2.

To solve this problem, first we need to clarify that the number must end with 5, because only in this way, after conversion, it will be an even number and can be divided by 2; and the first digit must be 2......

[ Last edited by youxi01 on 2006-11-16 at 11:38 PM ]
Floor24 youxi01 Posted 2006-11-15 07:46
高级用户 Posts 247 Credits 846 From 湖南==》广东
Answer to post 20: The answer is 10 11 12 13 14




Tested and passed under XP Pro SP2.

[ Last edited by youxi01 on 2006-11-16 at 11:38 PM ]
Floor25 zouzhxi Posted 2006-11-15 08:10
中级用户 Posts 177 Credits 430 From 广东深圳
At the request of namejm:


#Serial number! Solved? Unsolved

#01!
Find narcissistic numbers?

#02!
There are four numbers. When any three numbers are added together, the resulting sums are 84, 88, 99, 110 respectively. Find these four numbers?

#03!
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. These four-digit number and six-digit number exactly consist of the ten digits from 0 to 9.
Ask, what number should this be?

#04!
A total of 4889 digits were used to number the pages of a dictionary. How many pages does this dictionary have? Answer: 1499

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

#06!
There is a five-digit odd number. Replace all 2s with 5s and all 5s with 2s in this five-digit odd number, 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?

#07!
The sum of five consecutive natural numbers can be divisible by 2, 3, 4, 5, 6 respectively. Find the smallest set of numbers that meets this condition.

#08!
I am a three-digit number. There is one digit that is "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 I was originally?

#09?
Farmer Jones said to his wife: "Hey, Maria, if I sell 75 chicks according to my way, then our chicken feed can last for 20 days. However, if I 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?"
The problem is here. How many chicks do they have exactly?

#10!
Among all five-digit numbers, how many have exactly two 3s?

#11!
Divide 17 into the sum of several natural numbers. What is the maximum product of these natural numbers?

#12?
Multiply natural numbers 2, 3... together. The last 6 digits of their product are exactly all 0s. What is the minimum possible value of the last natural number?

#13!
The sum of the dividend, divisor and quotient is 181, and the quotient is 12. Find the dividend.


#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?

#15?
A number has a remainder of 2 when divided by 3 and a remainder of 1 when divided by 5. What is the remainder of this number when divided by 15?

#16?
1. p is a prime number, and p×p + 1 is also a prime number. Find 2006×p.
2. What is the remainder when the product of 2006 2s is divided by 7?



[ Last edited by zouzhxi on 2006-11-15 at 09:39 PM ]
Floor26 namejm Posted 2006-11-15 08:10
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Originally posted by youxi01 at 2006-11-14 18:24:
To solve this problem, first we need to clarify that the number must end with 5, because only in this way can it be an even number after conversion and be divisible by 2; and the first digit must be 2...

  The idea of 23F has flaws, because what we need to do is to simulate the problem statement with code. If we can directly deduce certain conditions, we can make full use of these conditions; if the conditions need to be deduced through more than two steps of reasoning, it is better not to use them and should be left to the code to handle; otherwise, since the conditions deduced through two steps of reasoning can be used, then what about three steps? Four steps? N steps? The last step is just included in the Nth step? In that case, we can completely write out the conclusion that needs to be deduced through N steps and thus completely abandon the code - although your result is correct in the end, it is suggested not to do this.

  Based on 23F, here is a code that solves the problem of 18F and tries to simulate the problem statement (very slow):

  Then here is a faster code:


  The code of 23F can be simplified as:


[ Last edited by namejm on 2006-11-15 at 12:57 PM" ]
Floor27 youxi01 Posted 2006-11-15 08:18
高级用户 Posts 247 Credits 846 From 湖南==》广东
I can't agree with the statement of the "moderator" above: "Because what we need to do is to simulate the problem with code. If we can directly derive some conditions, we can make full use of these conditions; if conditions that need more than two steps of reasoning to be obtained".

I once wrote a problem of finding prime numbers within 100,000 with (pure) batch processing. According to the statement above, if we simulate the problem, the running efficiency of the written code is really not to be praised!

For some derivable conclusions, especially those that can be derived quickly, I think they can all be applied.
Floor28 namejm Posted 2006-11-15 08:31
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Hehe, the approach of not agreeing is correct because I didn't state my precondition: when we want to study certain algorithms, we should try to write code simulating the problem statement; if it's writing scripts, based on the principle of , we can make full use of all correctly derivable conditions - the reason for proposing the statement of trying to simulate here is because we are mainly discussing general algorithms here. Of course, it doesn't mean excluding highly technical code.
Floor29 lxmxn Posted 2006-11-15 09:27
版主 Posts 4,938 Credits 11,386

  When playing number games with batch processing, you need to pay attention to the range of numbers, otherwise overflow will occur.

  -2147483648——2147483647 (WINDOWS XP SP2 @ CMD Shell)
Floor30 youxi01 Posted 2006-11-15 12:14
高级用户 Posts 247 Credits 846 From 湖南==》广东
Not bad, there are many questions! Let's answer a few first!

### Question 8:
```
@echo off
rem After deduction, the first digit must be 1, (unless the unknown number is 1, and the case where it is 1 is also handled in the first for)
setlocal enabledelayedexpansion
for /l %%i in (0 1 9) do (
set /a Fnum=1%%i3
set /a Bnum=3%%i4
set /a num=!Bnum!/2-9
if !Fnum! EQU !num! echo !Fnum!)

for /l %%i in (0 1 9) do (
set /a Fnum=13%%i
set /a Bnum=34%%i
set /a num=!Bnum!/2-9
if !Fnum! EQU !num! echo !Fnum!)
pause>nul

```

### Question 9:
```
@echo off
rem The number of chicks is at least 76:

setlocal enabledelayedexpansion
for /l %%i in (76 1 10000) do (
set /a Fnum=%%i*20-75*20
set /a Bnum=%%i*15+100*15
if !Fnum! EQU !Bnum! echo The number of chicks is: %%i & goto :exit)
:exit
pause>nul

```

### Question 10: Here is a relatively clever method: (the efficiency may be relatively high, not tested!)
```
@echo off
echo Detecting data........
setlocal enabledelayedexpansion
set /a flag=0
for /l %%i in (10000,1,99999) do (
set num=%%i
rem Adding a 1 in front is to prevent special cases like 30820.
set /a num=1!num:3=!
if !num! lss 2000 if !num! gtr 200 set /a flag+=1)
echo %flag%
echo Detection completed!
pause>nul
```

[ Last edited by youxi01 on 2006-11-16 at 11:41 PM ]
Prev  1 2 3 4 5 … 10  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023