RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00054

Redoks

Platinum II 플래티넘 II
난이도
3s
시간 제한
64MB
메모리 제한
1
맞았습니다!!
2
제출 수
50.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 \le A \le B \le 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 \le N \le 250\,000\), \(1 \le M \le 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 \le A \le B \le N\)).

출력 형식

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

Scoring: In \(30\%\) of all test cases, the numbers \(N\) and \(M\) will be less than \(1000\).

서브태스크
서브태스크점수설명

Subtask 1

90점
예제 1
입력
4 3
1234
1 4
1 4
1 4
출력
10
14
18
예제 2
입력
4 4
1234
1 1
1 2
1 3
1 4
출력
1
4
9
16
예제 3
입력
7 5
9081337
1 3
3 7
1 3
3 7
1 3
출력
17
23
1
19
5
문제 정보

riseoj 작성

출처 COCI 2007/2008 Contest 3

평가 및 의견

Redoks

개요
출제자 난이도 Platinum II 플래티넘 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Redoks

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8