#889
Platinum IV
REDOKS
시간 제한
3s
메모리 제한
64MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Luka is not paying attention in class again, while the teacher is explaining redox reactions. Instead of paying attention, he is playing with analog dials. An analog dial is a small device which always shows one digit between 0 and 9. It also contains a small button which increases the number by 1 (unless it is 9, in which case it is changed to 0). Luka has N such dials on his desk, numbered 1 to N left to right, and two sheets of paper for him to write on. Luka's game starts with him setting the dials in some starting configuration, which he then writes onto the first sheet. Luka then does the following M times:

  • Choose two integers A and B (1 ≤ A ≤ B ≤ N) and write them down on the first sheet.

  • Calculate the sum of numbers on dials numbered between A and B (inclusive), and write the

sum down on the second sheet.

  • Press the button once on all dials numbered between A and B.

Just as he had finished his game, the teacher noticed him, and took away all his dials and the second sheet of paper. Given the contents of the first sheet, help him calculate the numbers on the second sheet.

입력

The first line contains two integers N and M (1 ≤ N ≤ 250 000, 1 ≤ M ≤ 100 000). The second line contains the initial configuration of the dials, N decimal digits with no spaces. The first digit is the number initially on dial 1, the second digit the number on dial 2 and so on. Each of the following M lines contains two integers A and B (1 ≤ A ≤ B ≤ N).

출력

Output M lines, the sums calculated by Luka, in order in which he calculated them.

예제 입력 1

4 3
1234
1 4
1 4
1 4

예제 출력 1

10
14
18

예제 입력 2

4 4
1234
1 1
1 2
1 3
1 4

예제 출력 2

1
4
9
16

예제 입력 3

7 5
9081337
1 3
3 7
1 3
3 7
1 3

예제 출력 3

17
23
1
19
5
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Platinum IV1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.