中国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-24 20:11
47,812 topics / 349,917 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to find out which numbers in the text add up to a specified value
Printable Version  4,420 / 48
Floor16 youxi01 Posted 2007-03-03 06:50
高级用户 Posts 247 Credits 846 From 湖南==》广东
Comrade, it seems that among these 72 numbers, 8 numbers are repeated:


Do we only need to consider the other 64 numbers?!
Floor17 ccwan Posted 2007-03-03 06:54
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
It's not like that. For example: 4078 + 4078 + 4078 + 4052 + 4650 = 20936. If there are 3 4078s in test.txt, the above formula is allowed to appear.
Floor18 youxi01 Posted 2007-03-03 07:01
高级用户 Posts 247 Credits 846 From 湖南==》广东
This further increases the difficulty!

If only considering 64 non - repeating numbers, according to the calculation, at least 35 numbers are needed, and at most 37 numbers
Floor19 ccwan Posted 2007-03-03 07:05
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
This is an inevitable situation in practical applications. That is to say, if the code doesn't calculate the repeated numbers, it's just to practice everyone's hands, not to solve my problem. Please understand.
Floor20 youxi01 Posted 2007-03-03 07:16
高级用户 Posts 247 Credits 846 From 湖南==》广东
In fact, excluding the number of combined numbers between 35 and 37, according to the conventional method, the possible number of combinations is still an extremely large number.
Floor21 everest79 Posted 2007-03-03 07:18
金牌会员 Posts 1,127 Credits 2,564
It seems to take a lot of time, hehe, not tested



[ Last edited by everest79 on 2007-3-2 at 06:33 PM ]
Floor22 everest79 Posted 2007-03-03 07:39
金牌会员 Posts 1,127 Credits 2,564
Oh, it turned out to be a four-digit number, I mistook it for a five-digit number
Floor23 everest79 Posted 2007-03-03 08:15
金牌会员 Posts 1,127 Credits 2,564
Can't write anymore, too much
Floor24 vkill Posted 2007-03-03 09:20
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Such a difficult question is finally posted. Oh~ I can't figure it out, looking forward to experts
Floor25 zhoushijay Posted 2007-03-03 11:03
高级用户 Posts 375 Credits 845
Just a single math problem can kill a lot of brain cells, let alone designing an algorithm. -_-!
Floor26 slore Posted 2007-03-03 21:18
铂金会员 Posts 2,478 Credits 5,212
Sorted:



Sum of the largest 38 numbers
5348+5282+5266+5234+5224+5218+5206+5194+5174+5168+5164+5150+5134+5134+5130+5104+5076+5008+4948+4942+4896+4838+4830+4828+4828+4826+4824+4816+4808+4792+4784+4782+4776+4770+4762=175264

Sum of the smallest 39 numbers
3800+3858+4072+4162+4168+4188+4238+4240+4262+4270+4272+4322+4324+4498+4520+4616+4632+4682+4684+4704+4710+4712+4720+4720+4724+4724+4730+4730+4732+4742+4742+4744+4746+4754+4754+4760+4760+4762+4770=176548>171780
Then what does this indicate? It can only be 38 digits. (I casually calculated that the sum of the smallest 38 is 171778)


Thus, the number of digits is limited! The number of operations is reduced from 2^72 - 1 to 396561735952215036840 times, which is approximately 344 * 2^60 times... Although it is very large, you should know that 2^72 is about 11.9 times of it!
And the number of operations can be further reduced...
Floor27 slore Posted 2007-03-03 21:28
铂金会员 Posts 2,478 Credits 5,212
The sum of the smallest 38 numbers has a difference of 2 from the required number (171780 - 171778 = 2)

3800 + 3858 + 4072 + 4162 + 4168 + 4188 + 4238 + 4240 + 4262 + 4270 + 4272 + 4322 + 4324 + 4498 + 4520 + 4616 + 4632 + 4682 + 4684 + 4704 + 4710 + 4712 + 4720 + 4720 + 4724 + 4724 + 4730 + 4730 + 4732 + 4742 + 4742 + 4744 + 4746 + 4754 + 4754 + 4760 + 4760 + 4762

And the 39th number is 4770. The number closest to it is the 38th one (I sorted them in order). And this number 4762 has a difference from 4770 that is greater than 2.

That is to say, if 39 is replaced with 38, the number becomes larger by 6 (171786). And this number is the 2nd smallest number among the 38 numbers. All the subsequent numbers are larger than it!

So the final answer comes out!!!!!

Floor28 ccwan Posted 2007-03-03 21:49
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
re slore
There won't be no qualifying combinations as you said, because I got this result after a selection and then made the question.
Floor29 slore Posted 2007-03-03 21:53
铂金会员 Posts 2,478 Credits 5,212
Originally posted by ccwan at 2007-3-3 08:49:
re slore
There won't be no combination that meets the requirements as I got this result after a selection, and then made the question.


Is your number 38?

Send me the short message with your number.
I think the analysis is not wrong... It won't be a calculation issue~
Floor30 ccwan Posted 2007-03-03 21:59
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Sorry,Irandomlyselectedsomenumbers,gotaresultandsentitout,withoutrecordingwhichnumberstheywere,buttheremustbesuchcombinations.

Ifduetomyoversighttherereallyaren'tany,youcandefineoneyourselfaslongasitworks.
Prev  1 2 3 4  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023