![]() |
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.
|
|
| 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:
[ 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: 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 |