Program time limit: 1 second
Program memory limit: 512 MB
Isaiah is computing the sum of an array $a$, which contains $n$ integers: $a_1, a_2, \dots, a_n$.
After finding the sum, he can perform exactly one digit swap, which is done by swapping around any two digits. Digit sums can either be within the same number, or across different numbers. The only restriction is numbers cannot start with the digit $0$, unless the number is a single digit $0$.
How many different digit swaps are there which do not change the sum of array $A$? Since the answer can get big, please give your answer modulo $1,000,000,007$.
For all test cases:
Additionally:
You should read from standard input and write to standard output.
In Python, you could use the following code.
# Taking inputs, already done! :D
n = int(input())
A = list(map(int, input().split()))
ans = 0
# Write your code here
# Printing output
print(ans)
In C or C++, you could use the following code.
// Taking inputs, already done! :D
int n; scanf("%d", &n);
int A[n]; for (int i = 0; i < n; i++) scanf("%d", &A[i]);
int ans;
// Write your code here
// Printing output
printf("%d\n", answer);
2
123 330
6
These are four pairs of numbers with a sum of $453$: $323+130, 133+320, 120+333, 123+330$. Importantly, there are three swaps that result in $123+330$. Therefore, there are a total of $6$ valid digit swaps.
1
110
1
The only valid digit swap is between the $1$ in the hundreds position and the $1$ in the tens positions.
For each subtask (worth 50% and 50% of points, as per the Constraints section), your program will be run on multiple secret test cases one after another, and if it produces the correct output for all test cases, it solves that subtask. Your program will receive the points for each subtask it solves. Recall that your final score on the task is the score of your highest scoring submission.
Log in to submit!