Problem Statement You are given a string S of length N consisting of digits from 1…
- User
Problem Statement You are given a string S of length N consisting of digits from 1 through 9.
For each pair of integers (i,j) (1≤i≤j≤N), define f(i,j) as the value obtained by interpreting the substring of S from the i-th through the j-th character as a decimal integer. Find i=1 ∑ N
j=i ∑ N f(i,j).
Constraints 1≤N≤2×10 5
N is an integer. S is a string of length N consisting of digits from 1 through 9. Input The input is given from Standard Input in the following format:
N S Output Print the answer.
Sample Input 1 Copy 3 379 Sample Output 1 Copy 514 The answer is f(1,1)+f(1,2)+f(1,3)+f(2,2)+f(2,3)+f(3,3)=3+37+379+7+79+9=514.
Sample Input 2 Copy 30 314159265358979323846264338327 Sample Output 2 Copy 369673254065355789035427227741 type in c++
- Assistant