Attention, I may have misinterpreted the question and this solution may not present Carrys by mathematical method.
The mathematical solution that you want and that I developed (I don’t know if anyone has done this before, because I am an engineer and not a mathematician, if someone has a reference, please inform in the comments, that I make a point to analyze and quote here in this answer) is this:
Below is an example with the formulas of the cells shown beside (in this example, the column is "I" and the initial data line is 13)
How the calculations work:
First it is necessary to calculate the number number number number to be analyzed, this is done by means of the whole part of the result of the base logarithm 10 of that number plus one.
The base logarithm 10 for values like 10, 100 and 1000 only returns integers, respectively 1, 2 and 3 in this example (their respective powers).
Thus, an integer value that is between 10 3 (1000) and 10 4 (10000), will have the result of its base logarithm 10 between 3 and 4, never 3 (would be 1000) or 4 (would be 10000).
Thus, above 1000 (which has four digits, equal to its power plus one) and below 10000 (which has five digits, equal to its power plus one), all integers in this range must have four digits, and the result of their logarithms will always be greater than 3 and smaller than 4.
Therefore, taking the entire part of this calculation and adding one, we obtain the number of digits of the analyzed integer.
To be a Carry, all digits must be equal, so by obtaining the first digit of this number we can generate a Carry with it (of same digit numbers of the original value) and compare if they are equal.
Taking the entire part of the result of dividing this value by 10 to its number of digits and multiplying by 10, an integer is obtained which is the first digit of the analyzed value.
To repeat this digit by the number of digits of the analyzed value, it is necessary to obtain the same number of 1s, so that when multiplying by this first digit, the result returns its respective Carry.
Since 1/9 gives a tithe of 1s, just take the amount of 1s needed for multiplication.
This is done by calculating the entire part of the tithe times 10 to the number of digits.
By multiplying the first digit by the 1s, you get Carry.
By subtracting the value of the Carry obtained by the analyzed value, if the result is zero, it is a Carry, otherwise it is not a Carry.
The number of digits should be considered when Carry.
Do this for every part of your equation!
Olá amigo, sobre dúvidas com o URI você pode acesso direto o fórum do site - https://www.urionlinejudge.com.br/forum/ - It is easier for someone to help you there because many people have already solved the SAME problems.
– pmargreff