如何处理大数字?

发布于 2024-09-10 07:27:53 字数 1035 浏览 1 评论 0原文

可能的重复:
C 语言中的“BigInt”?
如何在 C++ 中实现 big int

我们如何处理大数不使用外部库和函数?

一些问题如下:

数字21000的各位数字之和是多少?

计算出以下一百个 50 位数字之和的前十位数字。

37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676
8926........................................771585
42502016545090413245809786882778948721859655517457
72107838435069186155435662884062257473692284509516
20849603980134001723930671666823555245252804609722
53503534226472524250874054075591789781264330331690

(这个清单还在继续......)

您将如何继续解决此类问题?我可以使用什么方法?

提前致谢。

*顺便说一句,这些问题取自欧拉计划,但许多其他实例不仅存在于此。我发现这些只是为了提供一个例子。

Possible Duplicates:
“BigInt” in C?
How to implement big int in C++

How do we work with big numbers without making use of external libraries and functions?

Some problems are as follows:

What is the sum of the digits of the number 21000?

Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.

37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676
8926........................................771585
42502016545090413245809786882778948721859655517457
72107838435069186155435662884062257473692284509516
20849603980134001723930671666823555245252804609722
53503534226472524250874054075591789781264330331690

(this list goes on...)

How would you go on to solve such problems? What approach can I use?

Thanks in advance.

*by the way, these problems are taken from Project Euler but many other instances exist not only there. I found these just to provide an example.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

<逆流佳人身旁 2024-09-17 07:27:53

您需要 GMP,GNU 多精度库。说真的,不要重新发明轮子。

You need GMP, the GNU multi-precision library. Seriously, don't re-invent the wheel.

闻呓 2024-09-17 07:27:53

构建您的 bigint 实现,或下载一个。

Build your bigint implementation, or download one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文