需要注意的都在代码注释里,自己看吧,欢迎讨论。
#include
#include
#include
using namespace std;
//模拟手工加法
string add(string str1, string str2)
{
int i;
string str;
int len_str1 = str1.length();
int len_str2 = str2....
分类:
其他好文 时间:
2015-03-20 18:46:10
阅读次数:
141
解决超大数相加的问题的一种思路是把整形转化成字符串,废话不多说直接上代码,已经调试通过。
#include
#include
#include
using namespace std;
string add(string str1, string str2)
{
int i;
string str;
int len_str1 = str1.length();
int len_...
分类:
其他好文 时间:
2015-03-20 00:06:39
阅读次数:
247
转自:http://blog.csdn.net/chhuach2005/article/details/211681791.题目 编写两个任意位数的大数相乘的程序,给出计算结果。2.题目分析 该题相继被ACM、华为、腾讯等选作笔试、面试题,若无准备要写出这种程序,还是要花一定的时间的。故,觉...
分类:
编程语言 时间:
2015-03-14 23:12:28
阅读次数:
364
这道题是大数相加问题,不算难,也没那么简单,要仔细。想到两种办法,第一种是使用交换区,另一种不使用交换区,更节省空间。 1 #include 2 #include 3 #include 4 5 6 int main(void) 7 { 8 char s1[1010], s2[101...
分类:
其他好文 时间:
2015-03-10 11:43:52
阅读次数:
133
详细题目点击:http://acm.hdu.edu.cn/showproblem.php?pid=1002
Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
...
分类:
其他好文 时间:
2015-03-09 09:28:55
阅读次数:
178
Problem Description
Recall the definition of the Fibonacci numbers:
f1 := 1
f2 := 2
fn := fn-1 + fn-2 (n >= 3)
Given two numbers a and b, calculate how many Fibonacci numbers are in the ...
分类:
其他好文 时间:
2015-03-04 16:56:45
阅读次数:
126
字符串的相乘,可用于解决大数相乘,注意首尾颠倒
class Solution {
public:
string multiply(string num1, string num2) {
if(num1 == "0" || num2 == "0") return "0";
int l1 = num1.length(), l2 = num2.length();
i...
分类:
其他好文 时间:
2015-03-01 21:04:55
阅读次数:
132
转载请注明出处:http://blog.csdn.net/u012860063题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047Problem DescriptionOne of the first users of BIT's new super...
分类:
其他好文 时间:
2015-02-14 18:48:52
阅读次数:
175
题意 从1开始 1变为01 0变为10 计数变换多少次后连续0序列的个数。题解 找规律(菲波数)+大数相加a[i]=a[i-1]+a[i-2]*2; 1 #include 2 #include 3 #include 4 #define N 1001 5 using namespace std; 6....
分类:
其他好文 时间:
2015-02-02 12:21:50
阅读次数:
275
【概述】
Karatsuba乘法是一种快速乘法。此算法在1960年由Anatolii Alexeevitch Karatsuba 提出,并于1962年得以发表。
此算法主要用于两个大数相乘。普通乘法的复杂度是n2,而Karatsuba算法的复杂度仅为3nlog3≈3n1.585(log3是以2为底的)
【步骤】
Karatsuba算法主要应用于两个大数的相乘,原理是将大数分成两段后变成较小...
分类:
编程语言 时间:
2015-01-28 19:50:40
阅读次数:
242