#P15983. [PA 2026] 列竖式 / Dodawanie
[PA 2026] 列竖式 / Dodawanie
Problem Description
Bajtek is learning column addition. He aligns three numbers of the same length digit by digit. He now wants to know how many pairs (where ) make the fragments of these three numbers from the -th digit to the -th digit form a correct addition equation (that is, the corresponding fragment of the third number equals the sum of the corresponding fragments of the first and second numbers). Leading zeros are allowed in all fragments.
Input Format
The input consists of three lines, each containing an integer (possibly starting with zeros). The three numbers have the same number of digits, all being digits long ().
Output Format
Output one integer, the number of pairs such that the fragments from column to column form a correct addition equation.
037523
040834
978367
4
Hint
Sample explanation: The correct addition equations correspond to the following pairs: (because ), (because ), (because ), and (because ). Note that the fragments corresponding to and are exactly the same, but we still count them separately, for a total of two times. For additions of misaligned fragments, such as , we do not count them.
Translated by ChatGPT 5