|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 31 楼』:
使用 LLM 解释/回答一下
随便给一个?那只能是把第39个换成4764...那样就唯一解。。
这个根据情况吧。否则计算量太大了。你看我说的那个累加次数!2的几十次方啊。
方法我觉得最省的就是:
1.排序
2.判断至少和至多的数字个数。
3.枚举这2个里面的数字。。。。
(这个枚举的过程我找下,懒的再想了,但是数字越多,运算就……)
Just give one randomly? Then it can only be that replacing the 39th one with 4764... Then there is a unique solution...
This depends on the situation. Otherwise, the amount of calculation is too large. You see the number of accumulation times I mentioned! Tens of powers of 2...
The method I think is the most economical is:
1. Sorting
2. Judging the number of numbers at least and at most.
3. Enumerating the numbers in these 2...
( I'll find this enumeration process later, too lazy to think again, but the more numbers, the more the operation...)
|
|
2007-3-3 22:05 |
|
|
qjbm
初级用户
 
积分 125
发帖 44
注册 2007-1-24
状态 离线
|
 『第 32 楼』:
使用 LLM 解释/回答一下
又见排列组合!
没有简单算法.
n=数组中数的个数
r=从 1 到 数组中数的个数总和
在nCr中枚举是否有符合条件.....
这种程序写完了也不适合在32位系统上运行...
--------------------------------------
若仅以解决本题可采用qzwqzw兄的递归代码稍加修改.
但计算速度还是要看运气........
@ECHO %DBG% OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A THE=171780
FOR /F %%n IN (TEST.TXT) DO (
SET /A i+=1
SET gn!i!=%%n
)
FOR /L %%j IN (1,1,%i%) DO CALL :REC %%j
GOTO :EOF
:REC
SETLOCAL
CALL SET tmp=%%gn%1%%
SET /A sum+=%tmp%
IF %sum% GTR %THE% GOTO :EOF
SET /A lvl+=1
IF %lvl% GTR 1 (
SET exp=%exp%+%tmp%
SET /A idx+=1
CLS & ECHO 第 !idx! 次计算
IF !sum! EQU %THE% (
ECHO !exp!=%sum%
ECHO 继续计算请按任意键&PAUSE>NUL
)
) ELSE (
SET exp=%tmp%
)
SET /A nxt=%1+1
FOR /L %%j IN (%nxt%,1,%i%) DO CALL :REC %%j
ENDLOCAL & SET idx=%idx%
GOTO :EOF
运气不错!
在进行103次计算时得到第一种结果:
4816+4776+4498+4616+4948+4684+4710+5266+4760+5168+4770+5134+5076+4784+5174+4732+4782+4746+4730+5224+5164+4742+4724+4730+4762+4162+4188+4830+4942+4072+4270+4520+4808+5130+4238+5104=171780
还是那句话,此题不宜在32位系统环境下解决.
下面的附件是在22万次计算后得到的321种结果!!!!!!
Last edited by qjbm on 2007-3-3 at 02:29 PM ]
Here comes permutations and combinations again!
There is no simple algorithm.
n = number of numbers in the array
r = from 1 to the sum of numbers in the array
Enumerate in nCr to see if there is a match.....
This kind of program is not suitable to run on a 32-bit system after being written...
--------------------------------------
If only to solve this problem, the recursive code of brother qzwqzw can be slightly modified.
But the calculation speed still depends on luck........
@ECHO %DBG% OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A THE=171780
FOR /F %%n IN (TEST.TXT) DO (
SET /A i+=1
SET gn!i!=%%n
)
FOR /L %%j IN (1,1,%i%) DO CALL :REC %%j
GOTO :EOF
:REC
SETLOCAL
CALL SET tmp=%%gn%1%%
SET /A sum+=%tmp%
IF %sum% GTR %THE% GOTO :EOF
SET /A lvl+=1
IF %lvl% GTR 1 (
SET exp=%exp%+%tmp%
SET /A idx+=1
CLS & ECHO 第 !idx! 次计算
IF !sum! EQU %THE% (
ECHO !exp!=%sum%
ECHO 继续计算请按任意键&PAUSE>NUL
)
) ELSE (
SET exp=%tmp%
)
SET /A nxt=%1+1
FOR /L %%j IN (%nxt%,1,%i%) DO CALL :REC %%j
ENDLOCAL & SET idx=%idx%
GOTO :EOF
Good luck!
Got the first result when performing the 103rd calculation:
4816+4776+4498+4616+4948+4684+4710+5266+4760+5168+4770+5134+5076+4784+5174+4732+4782+4746+4730+5224+5164+4742+4724+4730+4762+4162+4188+4830+4942+4072+4270+4520+4808+5130+4238+5104=171780
Still that sentence, this problem is not suitable to be solved in a 32-bit system environment.
The following attachment is 321 results obtained after 220,000 calculations!!!!!!
Last edited by qjbm on 2007-3-3 at 02:29 PM ]
此帖被 +5 点积分 点击查看详情 评分人:【 ccwan 】 | 分数: +5 | 时间:2007-3-4 22:02 |
|
附件
1: 结果.txt (2007-3-4 03:29, 60.98 KiB, 下载附件所需积分 1 点
,下载次数: 9)
|
|
2007-3-4 00:21 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
TO 26F:
如果考虑重复数字的话,
最大的数字组合只要35个,而非38个!
最小的数字组合需要38个
所以,真正的数字个数有35,36,37,38等情况。
如果按照常规办法的话,根据排列组合规律,数字将会极其庞大!我已经宣布退出,期待高手。
TO 26F:
If considering repeated numbers,
The largest number combination is only 35, not 38!
The smallest number combination requires 38.
So, the actual number of digits can be 35, 36, 37, 38, etc.
If following the conventional method, according to the permutation and combination rules, the number will be extremely large! I have announced my withdrawal and look forward to experts.
|
|
2007-3-4 01:21 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
Originally posted by youxi01 at 2007-3-3 12:21:
TO 26F:
如果考虑重复数字的话,
最大的数字组合只要35个,而非38个!
最小的数字组合需要38个
所以,真正的数字个数有35,36,37,38等情况。
如 ...
哦,知道意思了。。。。。。。。。。
Last edited by slore on 2007-3-3 at 12:47 PM ]
Originally posted by youxi01 at 2007-3-3 12:21:
TO 26F:
If considering repeated numbers,
The largest number combination only has 35, not 38!
The smallest number combination needs 38
So, the real number of digits has cases such as 35, 36, 37, 38, etc.
Such as...
Oh, got the meaning......
Last edited by slore on 2007-3-3 at 12:47 PM ]
|
|
2007-3-4 01:31 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 35 楼』:
使用 LLM 解释/回答一下
不是吧,效率这么低,那等我老了,都可能还没全部运算完
No way, the efficiency is so low. Then when I get old, it might not be fully calculated yet
|
|
2007-3-4 03:12 |
|
|
20080610
初级用户
 
积分 83
发帖 34
注册 2006-11-24
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
理想状况下从这些结果里筛选.
72!/35!(72-35)!+72!/36!(72-36)!+72!/37!(72-37)!+72!/38!(72-38)!
Under ideal conditions, filter from these results.
72!/(35!(72-35)!) + 72!/(36!(72-36)!) + 72!/(37!(72-37)!) + 72!/(38!(72-38)!)
|
|
2007-3-4 03:41 |
|
|
qjbm
初级用户
 
积分 125
发帖 44
注册 2007-1-24
状态 离线
|
『第 37 楼』:
使用 LLM 解释/回答一下
72!/35!(72-35)!+72!/36!(72-36)!+72!/37!(72-37)!+72!/38!(72-38)!
n=数组中数的个数
r=从 35 到 38
在nCr中枚举是否有符合条件.....
一样的.海量计算模式!!
72!/35!(72-35)! + 72!/36!(72-36)! + 72!/37!(72-37)! + 72!/38!(72-38)!
n = number of elements in the array
r = from 35 to 38
Enumerate in nCr to see if there are eligible ones.....
The same. Massive calculation mode!!
|
|
2007-3-4 03:48 |
|
|
20080610
初级用户
 
积分 83
发帖 34
注册 2006-11-24
状态 离线
|
『第 38 楼』:
使用 LLM 解释/回答一下
批处理应该是完成不料的...
Batch processing should be something that can't be completed...
|
|
2007-3-4 03:50 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 39 楼』:
使用 LLM 解释/回答一下
放弃了……
枚举的代码写出来了……运算的太慢了。
没响应……关闭了。。数太多了。。
Gave up...
The enumeration code has been written... It's too slow for the operation.
No response... Closed. Too many numbers..
|
|
2007-3-4 05:26 |
|
|
Primalchaos
初级用户
 
积分 41
发帖 19
注册 2006-12-15
状态 离线
|
『第 40 楼』:
使用 LLM 解释/回答一下
楼上何不将代码公布,让我们学习一下?
Why doesn't the person upstairs publish the code so that we can learn from it?
|
|
2007-3-4 05:28 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 41 楼』:
使用 LLM 解释/回答一下
不是用p写……
P运算的话更慢……
就是递归之类……网上搜索下 组合 递归。。算法很多的,dephi的,c的,vb的……
Not written with p...
The P operation is even slower...
It's recursion and so on... Search online for combination recursion. There are many algorithms, for Delphi, C, VB...
|
|
2007-3-4 05:41 |
|
|
Primalchaos
初级用户
 
积分 41
发帖 19
注册 2006-12-15
状态 离线
|
『第 42 楼』:
使用 LLM 解释/回答一下
那么兄可以给出c语言的代码吗?
Then can the brother provide the C language code?
|
|
2007-3-4 06:19 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
|
2007-3-4 06:35 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 44 楼』:
使用 LLM 解释/回答一下
不知道为什么,我写的一段代码,测出的36个数字组合要比32F的组数多的多?!
代码比32F的效率要高,但还是很不够,正在测试,稍候发布。
I don't know why, the 36-digit combinations I wrote out are much more numerous than the groups of 32F?! The code is more efficient than 32F, but it's still not enough. I'm testing it and will post it later.
|
|
2007-3-4 07:34 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
 『第 45 楼』:
使用 LLM 解释/回答一下
代码如下,欢迎测试,指正。
@echo off
setlocal enabledelayedexpansion
set num=0
for /f %%n in (test.txt) do (
set /a i+=1
set gn!i!=%%n
)
for /l %%i in (1,1,36) do call :rec %%i
pause
goto :eof
:rec
setlocal
set tmp=!gn%1!
set/a flag+=1
if %flag% EQU 1 (set str=%tmp%) else set str=%str%+%tmp%
set/a sum=%sum%+%tmp%
set /a nxt1=%1+1,nxt2=%1+36
if %nxt2% gtr 72 set/a nxt2=72
set /a lvl+=1
if %lvl% lss 36 (
for /l %%j in (%nxt1%,1,%nxt2%) do call :rec %%j
) else (
set/a idx+=1
title 正在检测第 %idx% 组数 已检测出 %num% 组数
if %sum% EQU 171780 echo %str%=171780 在第 %idx% 组数 & set/a num+=1
)
endlocal & set idx=%idx% & set num=%num%
说明:本段代码给出的是针对36个数字组合时的情况,其它情况不在考虑范围内,有需要请自行更改。
Last edited by youxi01 on 2007-3-4 at 07:50 AM ]
The code is as follows, welcome to test and give corrections.
@echo off
setlocal enabledelayedexpansion
set num=0
for /f %%n in (test.txt) do (
set /a i+=1
set gn!i!=%%n
)
for /l %%i in (1,1,36) do call :rec %%i
pause
goto :eof
:rec
setlocal
set tmp=!gn%1!
set/a flag+=1
if %flag% EQU 1 (set str=%tmp%) else set str=%str%+%tmp%
set/a sum=%sum%+%tmp%
set /a nxt1=%1+1,nxt2=%1+36
if %nxt2% gtr 72 set/a nxt2=72
set /a lvl+=1
if %lvl% lss 36 (
for /l %%j in (%nxt1%,1,%nxt2%) do call :rec %%j
) else (
set/a idx+=1
title Detecting group number %idx% %num% groups detected
if %sum% EQU 171780 echo %str%=171780 is in group number %idx% & set/a num+=1
)
endlocal & set idx=%idx% & set num=%num%
Description: This section of code is for the situation when there are 36 number combinations. Other situations are not considered. Please change it yourself if needed.
Last edited by youxi01 on 2007-3-4 at 07:50 AM ]
此帖被 +5 点积分 点击查看详情 评分人:【 ccwan 】 | 分数: +5 | 时间:2007-3-4 22:02 |
|
|
|
2007-3-4 07:48 |
|