|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 31 楼』:
使用 LLM 解释/回答一下
=============================
第11题稍微难一点。利用高中的数学知识可以证明,凡是大于等于4的数,它都可以这样的两个数,它们
的和与该数相等,乘积要大于等于该数。根据这样的推论,所有的数最后都会拆成这样的形式:
A*A*A*A....A为2或者3(因为只有2和3不能拆了,最后剩下的肯定只有2和3)。所以我们就可以得到下面
的代码:(答案是486,我不知道对不对^-^)
@echo off
setlocal enabledelayedexpansion
set num=17
set /a Cnum=%num%/3
set /a Rnum=%num%%%2
set /a Tnum=0
for /l %%i in (%Rnum% 2 %Cnum%) do (
set num_=1
set /a num_tem=%num%/2-%%i*3/2
for /l %%a in (1 1 %%i) do (
set /a num_*=3)
for /l %%b in (1 1 !num_tem!) do (
set /a num_*=2)
if !num_! gtr !Tnum! set /a Tnum=!num_!
)
echo !Tnum!
pause>nul
==================================
第12题,貌似比较简单,实则有点难..
@echo off
echo 正在检测数据........
setlocal enabledelayedexpansion
set /a num=1
set /a flag=0
for /l %%i in (2 1 10000) do (
call :test %%i
if !flag! equ 5 set /a num=%%i & goto :exit)
:exit
echo.
echo 最小的自然数为:!num!
echo.
echo 检测完毕!
pause>nul
:test
set /a num=!num!*%1
for /l %%i in (1 1 5) do (
if !num:~-1! EQU 0 (set /a flag+=1 & set /a num=!num:~0,-1!) else (
set /a num=!num:~-1! & goto :eof))
=============================================
第13题
@echo off
echo 正在检测数据........
setlocal enabledelayedexpansion
for /l %%a in (90 1 180) do (
for /l %%b in (1 1 %%a) do (
set /a num=%%a %% %%b
if !num! EQU 0 (
set /a num=%%a/%%b
set /a num_=!num!+%%a+%%b
if !num_! EQU 181 echo 这样的数有,被除数:%%a 除数:%%b 商:!num!
)
)
)
echo.
echo 检测完毕!
pause>nul
Last edited by youxi01 on 2006-11-16 at 11:33 PM ]
=============================
The 11th question is a bit more difficult. Using high school mathematics knowledge, it can be proved that for any number greater than or equal to 4, it can be expressed as the sum of two numbers, and the product of these two numbers is greater than or equal to the number. According to this inference, all numbers will eventually be broken down into such forms: A*A*A*A.... where A is 2 or 3 (because only 2 and 3 cannot be broken down further, and the remaining part must be only 2 and 3). So we can get the following code: (The answer is 486, I don't know if it's correct ^-^)
@echo off
setlocal enabledelayedexpansion
set num=17
set /a Cnum=%num%/3
set /a Rnum=%num%%%2
set /a Tnum=0
for /l %%i in (%Rnum% 2 %Cnum%) do (
set num_=1
set /a num_tem=%num%/2-%%i*3/2
for /l %%a in (1 1 %%i) do (
set /a num_*=3)
for /l %%b in (1 1 !num_tem!) do (
set /a num_*=2)
if !num_! gtr !Tnum! set /a Tnum=!num_!
)
echo !Tnum!
pause>nul
==================================
The 12th question seems relatively simple, but actually it's a bit difficult..
@echo off
echo Detecting data........
setlocal enabledelayedexpansion
set /a num=1
set /a flag=0
for /l %%i in (2 1 10000) do (
call :test %%i
if !flag! equ 5 set /a num=%%i & goto :exit)
:exit
echo.
echo The smallest natural number is:!num!
echo.
echo Detection completed!
pause>nul
:test
set /a num=!num!*%1
for /l %%i in (1 1 5) do (
if !num:~-1! EQU 0 (set /a flag+=1 & set /a num=!num:~0,-1!) else (
set /a num=!num:~-1! & goto :eof))
=============================================
13th question
@echo off
echo Detecting data........
setlocal enabledelayedexpansion
for /l %%a in (90 1 180) do (
for /l %%b in (1 1 %%a) do (
set /a num=%%a %% %%b
if !num! EQU 0 (
set /a num=%%a/%%b
set /a num_=!num!+%%a+%%b
if !num_! EQU 181 echo There are such numbers, dividend: %%a divisor: %%b quotient:!num!
)
)
)
echo.
echo Detection completed!
pause>nul
Last edited by youxi01 on 2006-11-16 at 11:33 PM ]
|
|
2006-11-15 14:47 |
|
|
zouzhxi
中级用户
   蝴蝶之吻
积分 430
发帖 177
注册 2006-9-20 来自 广东深圳
状态 离线
|
|
2006-11-15 21:42 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
先问问楼主:1、第十二题不是解决了吗?
2、第十一题的答案是否正确?
对于十四题,可能口算还更快,因为只有20,它比3的倍数多了2,所以答案是它(可以证明)!
程序代码为:
@echo off
set /a num=15+16+18+19+20+31
set Tnum=15 16 18 19 20 31
setlocal enabledelayedexpansion
rem ==========================
rem 第十四题:
for %%i in (15 16 18 19 20 31) do call :test %%i
echo 剩下的一包质量为:!result1!
echo 质量比较少的两包质量为:!result2! !result3!
pause>nul
:test
set /a num_tmp=%num%-%1
set /a Rnum=!num_tmp! %% 3
if !Rnum! NEQ 0 goto :eof
set Tnum_=!Tnum:%1 =!
set /a Snum=!num_tmp!/3
for %%a in (!Tnum_!) do (
set /a Rt=!Snum!-%%a
echo !Tnum_! | find "!Rt!" >nul 2>nul && (
set result3=%%a
set /a result2=!Rt!
set /a result1=%1))
Last edited by youxi01 on 2006-11-16 at 11:34 PM ]
First ask the building owner: 1. Isn't the twelfth question solved? 2. Is the answer to the eleventh question correct?
For question fourteen, mental arithmetic may be faster because there is only 20, which is 2 more than a multiple of 3, so the answer is it (can be proved)!
The program code is:
@echo off
set /a num=15+16+18+19+20+31
set Tnum=15 16 18 19 20 31
setlocal enabledelayedexpansion
rem ==========================
rem Question fourteen:
for %%i in (15 16 18 19 20 31) do call :test %%i
echo The remaining package mass is:!result1!
echo The two packages with less mass are:!result2! !result3!
pause>nul
:test
set /a num_tmp=%num%-%1
set /a Rnum=!num_tmp! %% 3
if !Rnum! NEQ 0 goto :eof
set Tnum_=!Tnum:%1 =!
set /a Snum=!num_tmp!/3
for %%a in (!Tnum_!) do (
set /a Rt=!Snum!-%%a
echo !Tnum_! | find "!Rt!" >nul 2>nul && (
set result3=%%a
set /a result2=!Rt!
set /a result1=%1))
Last edited by youxi01 on 2006-11-16 at 11:34 PM ]
|
|
2006-11-16 02:44 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
[建议]zouzhxi兄将1楼索引贴中其索引内容的题标下面加入解题人楼号、链接,
以备论坛访问者看到第1楼第1贴时,几秒钟内可迅速了解题目索引。
并快速可以点击链接进入其相应的索引页面(因有楼号提示,可快速找到)。
这对将来论坛重要、优秀等资源的索引、查找、参考、交流和别转载都起着非常方便、有效的作用~:)
#01 !
求水仙花数?
*************** 建议在这里加入不同解题人的楼号与URL链接 *****
如果有多个解题人,就加入多个URL不同页面的链接以及楼号:)
[建议]使用批处理方案解决和模拟数学算法以及数据结构相关的内容,
其本就身含具了一定量的批处理应用以及运算技巧。
但由于其数据结构以及算法的应用是使用批处理运算模拟完成的,
还含有批处理应用的一些技巧和使用经验,所以建议应适量的加入中文注解,
以备对数学和批处理希望再提高的网友参考与学习~:)
而且,这也是批处理中较“少见”的关于数学内容的知识贴~:)
所以建议精异求精,为增加论坛亮点和有论坛影响性的贴子传播再架高基础~:)
Last edited by redtek on 2006-11-16 at 03:19 AM ]
Brother zouzhxi, please add the building number of the problem solver and the link below the title of the index content in the index post on the first floor. So that when forum visitors see the first post on the first floor, they can quickly understand the title index within a few seconds. And quickly click the link to enter the corresponding index page (because the building number prompt allows quick finding). This is very convenient and effective for the future indexing, searching, reference, communication, and reprinting of important and excellent resources in the forum ~ : )
#01!
Find narcissistic numbers?
************************** It is suggested to add the building numbers and URL links of different problem solvers here **************************
If there are multiple problem solvers, add multiple URL links to different pages and building numbers : )
Use batch processing solutions to solve and simulate content related to mathematical algorithms and data structures. It inherently contains a certain amount of batch processing applications and operation skills.
However, since the application of its data structure and algorithm is completed by batch processing operation simulation, and it also contains some skills and usage experience of batch processing applications, it is suggested to appropriately add Chinese annotations for reference and learning by netizens who hope to further improve in mathematics and batch processing ~ : )
Moreover, this is also a relatively "rare" knowledge post about mathematical content in batch processing ~ : )
So it is suggested to strive for excellence, to lay a higher foundation for increasing the highlights of the forum and the spread of influential posts in the forum ~ : )
Last edited by redtek on 2006-11-16 at 03:19 AM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-16 03:11 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 35 楼』:
使用 LLM 解释/回答一下
回楼主:12题代码运行结果确实为:25,题目已解决!我是想问第11题的答案是不是486?!
==============
第15题
@echo off
setlocal enabledelayedexpansion
echo 在1~10000内,这样的数字以及除以15的余数分别为:
for /l %%i in (1 1 10000) do (
set /a num1=%%i %% 3
set /a num2=%%i %% 5
if !num1! EQU 2 if !num2! EQU 1 (
set /a Result=%%i
set /a num=!Result! %% 15
echo 数字:!Result! 余数:!num!
)
)
pause>nul
Last edited by youxi01 on 2006-11-16 at 11:34 PM ]
Reply to the owner: The code running result for question 12 is indeed: 25, and the question has been solved! I want to ask if the answer to question 11 is 486?!
==============
Question 15
@echo off
setlocal enabledelayedexpansion
echo Within 1~10000, such numbers and their remainders when divided by 15 are respectively:
for /l %%i in (1 1 10000) do (
set /a num1=%%i %% 3
set /a num2=%%i %% 5
if !num1! EQU 2 if !num2! EQU 1 (
set /a Result=%%i
set /a num=!Result! %% 15
echo Number: !Result! Remainder: !num!
)
)
pause>nul
Last edited by youxi01 on 2006-11-16 at 11:34 PM ]
|
|
2006-11-16 05:36 |
|
|
zouzhxi
中级用户
   蝴蝶之吻
积分 430
发帖 177
注册 2006-9-20 来自 广东深圳
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
回楼上:
是的,
分解成:3×3×3×3×3×2=486
这个乘积是最大的。
你12F的代码结果:
Last edited by zouzhxi on 2006-11-16 at 05:51 AM ]
Reply to the upstairs:
Yes,
Decomposed into: 3×3×3×3×3×2=486
This product is the largest.
The code result of your 12F:
Last edited by zouzhxi on 2006-11-16 at 05:51 AM ]
|

Butterfly Kiss Blog
计算机DIY联盟论坛 |
|
2006-11-16 05:41 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 37 楼』:
使用 LLM 解释/回答一下
1、对于16题的第一小题,我想的话,如果还写代码的话就太浪费了:
很容易证明P必须是偶数且又必须是质数,所以只能为2
2、至于第二小题,我看答案应该是4,利用高中的数列和排列组合的相关知识就可以搞定。如果纯粹写针对这个问题的代码那实在是....正在努力写一个具有一定通用性的代码
1、For the first sub-question of question 16, if I think about it, it's too wasteful to write code:
It's very easy to prove that P must be even and must also be a prime number, so it can only be 2
2、As for the second sub-question, I think the answer should be 4. It can be solved by using the relevant knowledge of high school sequences and permutations and combinations. If I just write code for this problem, it's really.... I'm working hard to write a relatively general-purpose code
|
|
2006-11-16 05:54 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 38 楼』:
使用 LLM 解释/回答一下
Re 36F,不好意思,12题的答案贴错了,贴到测试时的代码了,看更新后的代码!
Re 36F, sorry, the answer to question 12 was pasted incorrectly, it was pasted into the test code! Please see the updated code!
|
|
2006-11-16 06:01 |
|
|
zouzhxi
中级用户
   蝴蝶之吻
积分 430
发帖 177
注册 2006-9-20 来自 广东深圳
状态 离线
|
|
2006-11-16 06:44 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 40 楼』:
使用 LLM 解释/回答一下
===========================================
16.1在这里不写代码了,因为没什么好写的^_^,答案应该为5012
下面贴一贴 16.2的代码:
@echo off
setlocal enabledelayedexpansion
for %%i in (2 3 5 6 7 9 10 15 17 31 33 63 65) do (
set /a tmp=1
set /a Res=1
call :test %%i
echo 2^^^^2006除以%%i的余数为:!Res!)
pause>nul
::处理偶数
:test
if %1 GTR 2 (
set /a var=%1 %% 2
if !var! EQU 0 (
set /a num=%1/2
call :test !num!) else call :test1 %1) else set Res=0
goto :eof
:test1
for /l %%i in (1 1 10) do (
set /a tmp*=2
set /a Rnum=%1 %% 4
if !tmp! GEQ %1 (
if !Rnum! EQU 3 (
set /a Inum=%%i
set /a Inum_=2006 %% !Inum!
for /l %%a in (0 1 !Inum_!) do set /a Res*=2
set /a Res=!Res!/2
goto :eof)
set /a Inum=%%i-1
set /a Inum_=2006 %% !Inum!
for /l %%a in (0 1 !Inum_!) do set /a Res*=2
set /a Res=%1-!Res!/2
goto :eof
))
Last edited by youxi01 on 2006-11-16 at 11:35 PM ]
===========================================
Here, no code is written at 16.1 because there's nothing much to write ^_^, the answer should be 5012
Paste the code for 16.2 below:
@echo off
setlocal enabledelayedexpansion
for %%i in (2 3 5 6 7 9 10 15 17 31 33 63 65) do (
set /a tmp=1
set /a Res=1
call :test %%i
echo The remainder of 2^^^^2006 divided by %%i is: !Res!)
pause>nul
::Handle even numbers
:test
if %1 GTR 2 (
set /a var=%1 %% 2
if !var! EQU 0 (
set /a num=%1/2
call :test !num!) else call :test1 %1) else set Res=0
goto :eof
:test1
for /l %%i in (1 1 10) do (
set /a tmp*=2
set /a Rnum=%1 %% 4
if !tmp! GEQ %1 (
if !Rnum! EQU 3 (
set /a Inum=%%i
set /a Inum_=2006 %% !Inum!
for /l %%a in (0 1 !Inum_!) do set /a Res*=2
set /a Res=!Res!/2
goto :eof)
set /a Inum=%%i-1
set /a Inum_=2006 %% !Inum!
for /l %%a in (0 1 !Inum_!) do set /a Res*=2
set /a Res=%1-!Res!/2
goto :eof
))
Last edited by youxi01 on 2006-11-16 at 11:35 PM ]
|
|
2006-11-16 23:14 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 41 楼』:
使用 LLM 解释/回答一下
建议 youxi01 把代码部分用 [code] 和 [/code] 括起来,一来便于分清代码部分和非代码部分,二来也方便别人的复制粘贴。
It is suggested that youxi01 enclose the code part with and
, which is convenient to distinguish the code part from the non-code part and also facilitates others' copy-paste.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-11-16 23:18 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 42 楼』:
使用 LLM 解释/回答一下
===========================================
17题:数学奥赛题,很容易知道答案是2^64-1,重要的问题是如何计算出2^64这个极其庞大的数字,直接计算肯定是行不通的了,那只好采取 “曲线救国” 的办法。我把我采用的办法叫做 “钟表式分段计算法”,如果不是原创,请恕我卤莽!
以下代码是将数据分成了6段,每段6位数字来分别保存。它的基本原理是:当最后一段数据在乘以2以后,如果它的值大于1000000,则进位,将进位的数据加到前一段数据上,依次类推。该段代码目前支持200个2连续相乘,当然你可以“改装”,可以计算更庞大的数字。
1、以下是计算2^n的代码:
@echo off
setlocal enabledelayedexpansion
::初始化每段数据;
for /l %%i in (1 1 5) do set /a num%%i=0
set /a num6=1
for /l %%i in (1 1 64) do (
rem ================================================
rem 初始化 进位数据 和 分段数据的计算公式(就是乘以2)
for /l %%i in (1 1 5) do (
set /a num%%i_=0
set /a num%%i*=2)
set /a num6*=2
rem ================================================
for /l %%a in (6 -1 1) do (
rem 每段数据保存一个6位数;
if !num%%a! GTR 1000000 (
set /a Inum=%%a-1
set /a tmp=!num%%a!
rem ========================================================================
rem 前面这个1是从前面的数据段“借”来的;前面加个1是为了防止set /a test=0003
rem 类似情况的出现!
set /a num%%a=1!tmp:~-6!
rem ========================================================================
rem 前面一段的数据加上后面一段数据的进位数再减1,因为有个1被“借”掉了!
set /a num!Inum!+=!tmp:~0,-6!-1
)
)
)
rem ===================================================================
rem 扫尾工作,因为前面为了除错,采用了“借”数据的办法,下面就给它还原!
for /l %%a in (6 -1 4) do (
set /a Inum=%%a-1
set /a tmp=!num%%a!
set num%%a=!tmp:~1!
set /a num!Inum!+=!tmp:~0,1!)
rem ===================================================================
echo %num1% %num2% %num3% %num4% %num5% %num6%
pause>nul
2、要完全完成题目的要求,请拷贝以下代码!
@echo off
setlocal enabledelayedexpansion
::初始化每段数据;
for /l %%i in (1 1 5) do set /a num%%i=0
set /a num6=1
for /l %%i in (1 1 64) do (
rem ================================================
rem 初始化 进位数据 和 分段数据的计算公式(就是乘以2)
for /l %%i in (1 1 5) do (
set /a num%%i_=0
set /a num%%i*=2)
set /a num6*=2
rem ================================================
for /l %%a in (6 -1 1) do (
rem 每段数据保存一个6位数;
if !num%%a! GTR 1000000 (
set /a Inum=%%a-1
set /a tmp=!num%%a!
rem ========================================================================
rem 前面这个1是从前面的数据段“借”来的;前面加个1是为了防止set /a test=0003
rem 类似情况的出现!
set /a num%%a=1!tmp:~-6!
rem ========================================================================
rem 前面一段的数据加上后面一段数据的进位数再减1,因为有个1被“借”掉了!
set /a num!Inum!+=!tmp:~0,-6!-1
)
)
)
set /a num6-=1
rem ===================================================================
rem 扫尾工作,因为前面为了除错,采用了“借”数据的办法,下面就给它还原!
for /l %%a in (6 -1 4) do (
set /a Inum=%%a-1
set /a tmp=!num%%a!
set num%%a=!tmp:~1!
set /a num!Inum!+=!tmp:~0,1!)
rem ===================================================================
for %%i in (%num1% %num2% %num3% %num4% %num5% %num6%) do (
if %%i neq 0 set Result=!Result!%%i)
echo !Result!
pause>nul
Last edited by youxi01 on 2006-11-17 at 12:33 AM ]
===========================================
Question 17: Mathematical Olympiad problem. It is easy to know that the answer is 2^64 - 1. The important issue is how to calculate the extremely large number 2^64. Direct calculation is definitely not feasible, so we have to take the "detour" method. I call the method I adopted the "clock - type segmented calculation method". If it is not original, please forgive my rashness!
The following code divides the data into 6 segments, each segment with 6 digits to save respectively. Its basic principle is: when the last segment of data is multiplied by 2, if its value is greater than 1000000, carry over, and add the carried data to the previous segment of data, and so on. This code currently supports multiplying 2 continuously for 200 times. Of course, you can "modify" it to calculate more massive numbers.
1. The following is the code for calculating 2^n:
@echo off
setlocal enabledelayedexpansion
::Initialize each segment of data;
for /l %%i in (1 1 5) do set /a num%%i=0
set /a num6=1
for /l %%i in (1 1 64) do (
rem ================================================
rem Initialize carry data and the calculation formula of segmented data (that is, multiply by 2)
for /l %%i in (1 1 5) do (
set /a num%%i_=0
set /a num%%i*=2)
set /a num6*=2
rem ================================================
for /l %%a in (6 -1 1) do (
rem Each segment of data saves a 6 - digit number;
if !num%%a! GTR 1000000 (
set /a Inum=%%a-1
set /a tmp=!num%%a!
rem ========================================================================
rem The previous 1 is borrowed from the previous data segment; adding a 1 in front is to prevent the occurrence of situations like set /a test=0003!
set /a num%%a=1!tmp:~-6!
rem ========================================================================
rem The previous segment of data adds the carry number of the subsequent segment of data and subtracts 1, because a 1 is "borrowed"!
set /a num!Inum!+=!tmp:~0,-6!-1
)
)
)
rem ===================================================================
rem Tail - cleaning work. Because for debugging, the method of "borrowing" data is adopted above, and now it is restored!
for /l %%a in (6 -1 4) do (
set /a Inum=%%a-1
set /a tmp=!num%%a!
set num%%a=!tmp:~1!
set /a num!Inum!+=!tmp:~0,1!)
rem ===================================================================
echo %num1% %num2% %num3% %num4% %num5% %num6%
pause>nul
2. To completely meet the requirements of the problem, please copy the following code!
@echo off
setlocal enabledelayedexpansion
::Initialize each segment of data;
for /l %%i in (1 1 5) do set /a num%%i=0
set /a num6=1
for /l %%i in (1 1 64) do (
rem ================================================
rem Initialize carry data and the calculation formula of segmented data (that is, multiply by 2)
for /l %%i in (1 1 5) do (
set /a num%%i_=0
set /a num%%i*=2)
set /a num6*=2
rem ================================================
for /l %%a in (6 -1 1) do (
rem Each segment of data saves a 6 - digit number;
if !num%%a! GTR 1000000 (
set /a Inum=%%a-1
set /a tmp=!num%%a!
rem ========================================================================
rem The previous 1 is borrowed from the previous data segment; adding a 1 in front is to prevent the occurrence of situations like set /a test=0003!
set /a num%%a=1!tmp:~-6!
rem ========================================================================
rem The previous segment of data adds the carry number of the subsequent segment of data and subtracts 1, because a 1 is "borrowed"!
set /a num!Inum!+=!tmp:~0,-6!-1
)
)
)
set /a num6-=1
rem ===================================================================
rem Tail - cleaning work. Because for debugging, the method of "borrowing" data is adopted above, and now it is restored!
for /l %%a in (6 -1 4) do (
set /a Inum=%%a-1
set /a tmp=!num%%a!
set num%%a=!tmp:~1!
set /a num!Inum!+=!tmp:~0,1!)
rem ===================================================================
for %%i in (%num1% %num2% %num3% %num4% %num5% %num6%) do (
if %%i neq 0 set Result=!Result!%%i)
echo !Result!
pause>nul
Last edited by youxi01 on 2006-11-17 at 12:33 AM ]
|
|
2006-11-16 23:28 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 43 楼』:
使用 LLM 解释/回答一下
========================================
18题:这个纯粹就是排列组合的问题了,实际上就是用批处理来处理排列组合公式!
代码:求出来的结果是1023,不知道对不?
@echo off
setlocal enabledelayedexpansion
set /a num=1
set /a Result=0
for /l %%i in (1 1 10) do (
call :test %%i 10
set /a Result+=!num! & set /a num=1)
echo 币值种类有:!Result!
pause>nul
::求C(n,r);
:test start_num end_num
set /a tmp=%2-%1+1
for /l %%i in (%tmp% 1 %2) do set /a num*=%%i
for /l %%i in (1 1 %1) do set /a num/=%%i
Last edited by youxi01 on 2006-11-16 at 11:37 PM ]
========================================
Question 18: This is purely a problem of permutations and combinations. Actually, it's about using batch processing to handle the permutations and combinations formula!
Code: The result obtained is 1023. I don't know if it's correct?
@echo off
setlocal enabledelayedexpansion
set /a num=1
set /a Result=0
for /l %%i in (1 1 10) do (
call :test %%i 10
set /a Result+=!num! & set /a num=1)
echo There are !Result! types of currency values
pause>nul
:: Find C(n,r);
:test start_num end_num
set /a tmp=%2-%1+1
for /l %%i in (%tmp% 1 %2) do set /a num*=%%i
for /l %%i in (1 1 %1) do set /a num/=%%i
Last edited by youxi01 on 2006-11-16 at 11:37 PM ]
|
|
2006-11-16 23:31 |
|
|
zouzhxi
中级用户
   蝴蝶之吻
积分 430
发帖 177
注册 2006-9-20 来自 广东深圳
状态 离线
|
『第 44 楼』:
使用 LLM 解释/回答一下
Re 42F:
对了,
就是在数字前面多了两0,数字中间有空格,看起来不像是一个答案,
而是一组数组。。。,
可不可以把它去掉。。。
Re 43F:
一开始,我就算错了。后来才发现在最后要减去1,
我的答案一开始是:1024的
没有排除每一种组合都不选的情况。。。
答案是:1023
Re 42F:
By the way,
It's just that there are two more 0s in front of the number and spaces in the middle of the number. It doesn't look like an answer, but a group of arrays... Can it be removed...
Re 43F:
At first, I miscalculated. Later, I found out that I need to subtract 1 at the end.
My initial answer was: for 1024
I didn't exclude the situation where none of the combinations are selected...
The answer is: 1023
|

Butterfly Kiss Blog
计算机DIY联盟论坛 |
|
2006-11-16 23:55 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 45 楼』:
使用 LLM 解释/回答一下
42F贴子已经修改,如你所愿!
The post with ID 42F has been modified as you wished!
|
|
2006-11-17 00:34 |
|