시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 128 MB 53 31 24 60.000%

문제

두 정수의 거리는 각 자리의 차이의 절댓값의 합으로 정의할 수 있다. 예를 들어, 4561과 3278의 거리는 |4 - 3| + |5 - 2| + |6 - 7| + |1 - 8| = 12 이다. 두 정수의 길이가 일치하지 않는 경우에는 앞에 0을 붙인다. 따라서, 32와 5678의 거리는 |0 - 5| + |0 - 6| + |3 - 7| + |2 - 8| = 21이 된다.

두 정수 A와 B가 주어졌을 때, 구간 [A,B]에 포함되는 모든 쌍의 거리의 합을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 두 정수 A와 B가 주어진다. (1 ≤ A ≤ B ≤ 1050000)

출력

첫째 줄에 구간 [A,B]에 포함되는 모든 쌍의 거리의 합을 출력한다. 답이 매우 커질 수 있으므로 1,000,000,007로 나눈 나머지를 출력한다.

예제 입력 1

288 291

예제 출력 1

76

힌트

(288, 289) = 1, (288, 290) = 9, (288, 291) = 8, (289, 290) = 10, (289, 291) = 9, (290, 291) = 1. 각 쌍을 두 번씩 더하면 2 * (1 + 9 + 8 + 10 + 9 + 1) = 76.

W3sicHJvYmxlbV9pZCI6Ijk2MjkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI0NTAgXHVjODE1XHVjMjE4XHVjNzU4IFx1YWM3MFx1YjlhYyIsImRlc2NyaXB0aW9uIjoiPHA+XHViNDUwIFx1YzgxNVx1YzIxOFx1Yzc1OCBcdWFjNzBcdWI5YWNcdWIyOTQgXHVhYzAxIFx1Yzc5MFx1YjlhY1x1Yzc1OCBcdWNjMjhcdWM3NzRcdWM3NTggXHVjODA4XHViMzEzXHVhYzEyXHVjNzU4IFx1ZDU2OVx1YzczY1x1Yjg1YyBcdWM4MTVcdWM3NThcdWQ1NjAgXHVjMjE4IFx1Yzc4OFx1YjJlNC4gXHVjNjA4XHViOTdjIFx1YjRlNFx1YzViNCwgNDU2MVx1YWNmYyAzMjc4XHVjNzU4IFx1Y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