StellarSpecter's blog

By StellarSpecter, history, 19 months ago, In English

Given two numbers represented as strings a and b, compute their product and output product as a string.

|a| <=1e6, |b|<=1e6

How do I solve it, I brute forced it and it gives me TLE.

can anyone help me? is there an optimal way ??

  • Vote: I like it
  • -10
  • Vote: I do not like it

| Write comment?
»
19 months ago, hide # |
 
Vote: I like it +21 Vote: I do not like it
»
19 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

So we have $$$10^{10^6} \cdot 10^{10^6} = 10^{2000000}$$$ , bro go create some new structure for such numbers

»
19 months ago, hide # |
Rev. 2  
Vote: I like it +10 Vote: I do not like it

Using FFT it can be solved in O(nlogn), n = max ( | a | , | b | ).

Check this out