Logo
(追記) (追記ここまで)

10397번 - Counting substhreengs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB88656279.487%

문제

Substrings are strings formed by choosing a subset of contiguous characters from a string. This is well known. A little more obscure is the definition of substhreengs. A substhreeng is a substring which complies to the following additional requirements:

  1. It is non-empty, and composed entirely of base 10 digits.
  2. Interpreted in base 10 (allowing extra leading zeros), the resulting integer is a multiple of 3.

For instance, the string “130a303” contains 9 substhreengs: the substhreeng “3” three times, the substhreengs “30” and “0” twice each, and the substhreengs “303” and “03” once each. The substring “30a3” is not a substhreeng because it is not composed entirely of base 10 digits, while the substring “13” is not a substhreeng because 13 is not a multiple of 3.

Notice that two substhreengs are considered different if they are different in length or start at a different position, even if the selected characters are the same.

Given a string, you are asked to count the number of substhreengs it contains.

입력

The input consists of a single line that contains a non-empty string S of at most 106 characters. Each character of S is either a digit or a lowercase letter.

출력

Output a line with an integer representing the number of substhreengs contained in S.

제한

예제 입력 1

130a303

예제 출력 1

9

예제 입력 2

0000000000

예제 출력 2

55

예제 입력 3

icpc2014regional

예제 출력 3

2

힌트

출처

ICPC > Regionals > Latin America > Latin America Regional Contests > Latin America Regional Contests 2014 C번

  • 문제를 만든 사람: Pablo Ariel Heiber
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /