Cody

Problem 42636. Big Integer Multiplication

Solution 750519

Submitted on 30 Sep 2015 by Peng Liu
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% Coutresy of Alfonso Nieto-Castanon urlwrite('https://sites.google.com/a/alfnie.com/alfnie/software/SetSolutionScore.p?attredirects=0&d=1','SetSolutionScore.p'); rehash path;

2   Pass
%% a = [1 2 3;0 5 6]; b = [5 6;9 0]; c = BigIntMult(a,b); assert(isequal(c(:,find(any(c,1),1):end),[6 8 8 8;5 0 4 0]))

3   Pass
%% n = 1e2; m = 20; a = randi([0 9],n,m); b = randi([0 9],1,m); c = BigIntMult(a,b); for k = 1:n d = c(k,:); d = d(:,find(d,1):end); assert(isequal(char(multiply(java.math.BigInteger(char(48+a(k,:))),java.math.BigInteger(char(48+b))))-48,d)) end

4   Pass
%% n = 1e2; m = 1e5; a = randi([0 9],n,m); b = randi([0 9],n,m); t1 = builtin('tic'); c = BigIntMult(a,b); score = builtin('toc',t1); for k = randi(n,1,3) d = c(k,:); d = d(:,find(d,1):end); assert(isequal(char(multiply(java.math.BigInteger(char(48+a(k,:))),java.math.BigInteger(char(48+b(k,:)))))-48,d)) end SetSolutionScore(round(5*score))

ans = 7

Suggested Problems

More from this Author8