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

32806번 - Average Substring Value 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB47262253.659%

문제

Let $s$ be a nonempty string consisting entirely of base-10ドル$ digits (0-9). If the length of $s$ is $n,$ number the digits 1,ドル 2, 3, \ldots, n$ from left to right, and for 1ドル \leq i \leq j \leq n,$ let $s[i,j]$ denote the substring consisting of the digits from position $i$ to position $j,ドル inclusive. (It follows that we are only considering nonempty substrings.) Assign a value to each substring that is simply equal to the largest digit in the substring. What is the average value of the substrings of $s$?

Note that two different substrings may be identical (as strings), but for the purposes of this problem they are treated as distinct. For example, if $s = $1010, then $s[1,2] = s[3,4] = $10 are distinct substrings (both with value 1ドル$).

입력

The input is a single nonempty string, $s,$ of base-10ドル$ digits. The length of $s$ is at most 200ドル,000円$.

출력

Output a line containing the average value of the substrings of $s$. If the average is an integer, print the integer. If the average is a proper fraction, i.e., is equal to $a/b,ドル where $a$ and $b$ are positive integers and $a < b,ドル print this fraction in lowest terms, with a '/' symbol separating the numerator and denominator. If the average is greater than 1ドル$ and does not simplify to an integer, print the whole part followed by the proper fractional part, separated by a space, with the proper fractional part in lowest terms and formatted as described in the previous sentence.

제한

예제 입력 1

123

예제 출력 1

2 1/3

예제 입력 2

4084

예제 출력 2

6

예제 입력 3

1010

예제 출력 3

4/5

예제 입력 4

00000

예제 출력 4

0

힌트

출처

ICPC > Regionals > North America > East Central North America Regional > 2024 East Central NA Regional Contest B번

ICPC > Regionals > North America > Greater New York Region > 2024 Greater New York Regional Contest B번

ICPC > Regionals > North America > Northeast North America Regional > 2024 Northeast North America Regional Contest B번

  • 문제를 만든 사람: Liam Keliher
(追記) (追記ここまで)

출처

대학교 대회

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

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