如何使用大号码? [英] How to work with BIG numbers?

查看:96
本文介绍了如何使用大号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能的副本:

“ BigInt”

如何实现大型C ++中的int

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

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

一些问题如下:

该数字的总和是多少? 21000吗?

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

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

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

(此列表继续...)

您将如何解决此类问题?我可以使用哪种方法?

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

预先感谢。

*顺便说一下,这些问题来自欧拉计划(Euler Project),但不仅存在于此,还有许多其他实例。我发现这些只是为了提供示例。

*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.

推荐答案

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

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

这篇关于如何使用大号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆