高精度计算
文章平均质量分 71
庞老板
思考时啃啃手指头会更有灵感
展开
-
超大整数加法模板
写下来,以备不时之需。 #define LENGTH 1005 #define LAST LENGTH-2 //函数要求sum的初始值均为0 char* IntegerAddition(char *a, char *b, char *sum) { int i, j, k, first; //从末位开始,把a与b对应位的和存入sum中,暂不处理进位 for (i = strlen(a)原创 2012-11-29 18:12:42 · 1027 阅读 · 1 评论 -
超大整数加法
#include #include char* Add(char *big, char *small) //将位数较短的数加在较长的数上 { if (strlen(big) < strlen(small)) { char *temp = big; big = small; small = temp; } big[0] = small[0] = '0'; int i =原创 2012-10-22 11:48:03 · 957 阅读 · 0 评论 -
二分查找+大整数加法——Poj 2413 How many Fibs?
How many Fibs? Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9710 Accepted: 3622 Description Recall the definition of the Fibonacci numbers: f1 := 1原创 2013-03-23 20:23:02 · 2335 阅读 · 0 评论 -
二分法+高精度——Poj 2109 Power of Cryptography(double型开n次方的方法通过的原因)
Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14584 Accepted: 7412 Description Current work in cryptography involves (among other原创 2012-12-06 12:20:56 · 5541 阅读 · 2 评论 -
超大整数乘法模板(高精度乘以低精度)
#include #include #include #include using namespace std; #define SIZE #define LENGTH 1000 #define LAST LENGTH-2 char a[LENGTH], result[LENGTH]; //multiplier最大值200,000,000,product的初值为0 char *In原创 2012-11-29 18:32:35 · 2484 阅读 · 0 评论 -
超大整数减法模板
#include #include #include using namespace std; #define LENGTH 100 #define LAST LENGTH-2 char a[LENGTH], b[LENGTH], result[LENGTH]; bool LessThan(char *a, char *b) { //去除前导'0' for (a; *a == '原创 2012-11-29 18:25:59 · 1010 阅读 · 0 评论