JEDNAKOS - JEDNAKOST
While browsing a math book, Mirko found a strange equation of the form A=S.What makes the equation strange is that A and S are not the same,which makes the equation incorrect. Mirko realized that the left side of the equation should have addition operations between some pairs of digits in A. Write a program that inserts the smallest number of addition operations on the left side to make the equation correct. The numbers in the corrected equation may contain arbitrary amounts of eading zeros.
The first line contains the equation in the form A=S.
A and S will both be positive integers without leading zeros. They will be different.
A will contain at most 1000 digit
S will be less than or equal to 5000
Note: The input data will guarantee that a solution, although not necessarily unique, will always exist.
Output the number of addition operations needed
Input: 143175=120 Output: 2
Input: 5025=30 Output: 1
Input: 999899=125 Output: 4
try to eliminate zeros at left side to achieve ac.
I passed all test cases by COCI, and got runtime error (SIGSEGV) here @@Last edit: 2017-08-20 15:14:30
tle with java , I think this judge put one time for all languages . I'm sure from the solution , and this not the first problem that I have met this problem
if there is test case:
Last edit: 2015-12-30 12:06:35
Care about ending zeros caused me a lot of WA. All in all not hard problem except that small corner case.
11th case = TLE !