问题描述
我想工作,通过对问题的 projecteuler.net ,但我一直运行到几个问题。
I'm trying to work through the problems on projecteuler.net but I keep running into a couple of problems.
首先是存储在名单,其中元素的大quanities的问题; T>
。我一直在列表中存储大量时获得OutOfMemoryException异常的。
The first is a question of storing large quanities of elements in a List<t>
. I keep getting OutOfMemoryException's when storing large quantities in the list.
现在我承认我可能不会做这些事情的最佳途径,但是,有没有定义的一些方法的应用程序可以有多少内存占用?
Now I admit I might not be doing these things in the best way but, is there some way of defining how much memory the app can consume?
它通常会崩溃,当我得到关于云燕亿元素:•
It usually crashes when I get abour 100,000,000 elements :S
其次,一些问题需要添加大量的数字。我用,我觉得数字是会得到超级大ULONG数据类型,但我还是设法换过去最大的支持int和进入负数。
Secondly, some of the questions require the addition of massive numbers. I use ulong data type where I think the number is going to get super big, but I still manage to wrap past the largest supported int and get into negative numbers.
你有什么秘诀与令人难以置信的大量的工作?
Do you have any tips for working with incredibly large numbers?
推荐答案
您需要使用使用一些基本的数学校长分裂这些操作了一大批类。这实现对codePoject一个C#的BigInteger库似乎是最有前途的。文章与庞大的数字是如何工作的操作的一些很好的解释,也是如此。
You need to use a large number class that uses some basic math principals to split these operations up. This implementation of a C# BigInteger library on CodePoject seems to be the most promising. The article has some good explanations of how operations with massive numbers work, as well.
另请参阅:http://stackoverflow.com/questions/176775/big-integers-in-c
这篇关于与令人难以置信的大量使用.NET的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!