We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Although Lisp can handle numbers as big as 10^100000 the program will time out for the big test cases. I suspect that division is implemented as a repeated shift and subtract operation so that repeatedly dividing 10^n by 10 (to get the individual digits) will run in O(n^2) time.
The solution is to read the first number as a character string and process each character one at a time.
Super Digit
You are viewing a single comment's thread. Return to all comments →
Although Lisp can handle numbers as big as 10^100000 the program will time out for the big test cases. I suspect that division is implemented as a repeated shift and subtract operation so that repeatedly dividing 10^n by 10 (to get the individual digits) will run in O(n^2) time.
The solution is to read the first number as a character string and process each character one at a time.