[英]How to divide a very large number(10^100), when number is stored as single digits in array
Say there is a very large number, 100 digits which is stored in an array. 假设有一个非常大的数字,100位数字存储在一个数组中。 Now i want to divide this number by another number(say 2) , Can anyone suggest how to do it?
现在我想将这个数字除以另一个数字(比如2),任何人都可以建议怎么做?
Try to do it exactly as you would do that on paper. 尝试完全像在纸上那样做。 For small divisors (as 2) this is an O(d) algorithm (where d is the number of digits) and it is impossible to find anything asymptotically better since you need to check each digit at least once.
对于小除数(如2),这是一个O(d)算法(其中d是数字的位数)并且由于您需要至少检查一次每个数字,因此无法找到渐近更好的任何东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.