一开始写的是这样:
用了书上写的ID函数,然后存二元组使用的大数相乘的方法,因为看错题目BIG一开始定义为10010,错了好几次找了半天错误=.=
后来发现存二元组也可以用make_pair(x,y)#include
#include
#include
#include
#include
#define B...
分类:
其他好文 时间:
2015-05-03 16:04:37
阅读次数:
99
计算1-100卡特兰数,必须要用数组存,大数模板注:卡特兰数:卡特兰数又称卡塔兰数,是组合数学中一个常出现在各种计数问题中出现的数列。由以比利时的数学家欧仁·查理·卡塔兰 (1814–1894)命名。原理: 令h(1)=1,h(0)=1,catalan数满足递归式: h(n)= h(0)*h(...
分类:
其他好文 时间:
2015-04-30 21:46:27
阅读次数:
318
Problem Description
As we all know the Train Problem I, the boss of the Ignatius Train Station want to know if all the trains come in strict-increasing order, how many orders that all the trains can get out of the railway.
Input
The input contains sever...
分类:
其他好文 时间:
2015-04-03 17:22:48
阅读次数:
145
需要注意的都在代码注释里,自己看吧,欢迎讨论。
#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
转自:http://blog.csdn.net/chhuach2005/article/details/211681791.题目 编写两个任意位数的大数相乘的程序,给出计算结果。2.题目分析 该题相继被ACM、华为、腾讯等选作笔试、面试题,若无准备要写出这种程序,还是要花一定的时间的。故,觉...
分类:
编程语言 时间:
2015-03-14 23:12:28
阅读次数:
364
字符串的相乘,可用于解决大数相乘,注意首尾颠倒
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
【概述】
Karatsuba乘法是一种快速乘法。此算法在1960年由Anatolii Alexeevitch Karatsuba 提出,并于1962年得以发表。
此算法主要用于两个大数相乘。普通乘法的复杂度是n2,而Karatsuba算法的复杂度仅为3nlog3≈3n1.585(log3是以2为底的)
【步骤】
Karatsuba算法主要应用于两个大数的相乘,原理是将大数分成两段后变成较小...
分类:
编程语言 时间:
2015-01-28 19:50:40
阅读次数:
242
通常解决大数运算数据超出范围,溢出的问题。一般采用数组去模拟。求算n!可以看成是每次两个整数相乘的过程,因此可以模拟成大数相乘的过程。只是需要增加一些变量去存储中间的进位和当前位的数值。...
分类:
其他好文 时间:
2015-01-25 15:17:14
阅读次数:
183
hdu 1402 A * B Problem Plus (FFT + 大数相乘)—— black 的专栏 —— waShaXiu...
分类:
其他好文 时间:
2015-01-20 18:03:00
阅读次数:
183
问题描述:定义大数d为一个数组,表示为:d=a[k-1]*10^(k-1)+a[k-2]*10^(k-2)+...+a[1]*10+a[0](k为数组长度),实现一个函数,返回两个大数相乘的结果
/**
d1=a[k-1]*10^(k-1)+a[k-2]*10^(k-2)+...+a[1]*10+a[0]
d2=b[l-1]*10^(l-1)+b[l-2]*10^...
分类:
其他好文 时间:
2014-12-07 11:22:11
阅读次数:
171