当然,这个特殊的表达式应该进行优化,但至于标题问题,我喜欢GMP,因为它提供了一个不错的C++界面,并且很容易获得.
#include <iostream>
#include <gmpxx.h>
mpz_class fact(unsigned int n)
{
mpz_class result(n);
while(n --> 1) result *= n;
return result;
}
int main()
{
mpz_class result = fact(100) / fact(99);
std::cout << result.get_str(10) << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
用Linux编译 g++ -Wall -Wextra -o test test.cc -lgmpxx -lgmp