E. CS240 project Problem 4

    Type: Default 2000ms 256MiB

CS240 project Problem 4

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

Consider an infinite sequence of numbers consisting of all natural numbers arranged in ascending order. That is, consider the sequence S=12345678910111213141516171819202122S = 12345678910111213141516171819202122 \ldots. Let SiS_i denote the ii'th number in the sequence; \emph{e.g.} S1=1,S2=2,,S10=1,S11=0S_1 = 1, S_2 = 2, \ldots, S_{10} = 1, S_{11} = 0, etc.

Let BB be a given input value. Give an algorithm to compute the smallest index in SS where BB occurs. For example, if B=101B=101, then the index is 10, since S10S11S12=101S_{10} S_{11} S_{12} = 101, and no earlier substring of SS equals 101.

Format

Input

A string representing the value BB, with no more than 200 digits.

Output

he smallest positive integer kk for which $B_{1}=S_{k}, B_{2}=S_{k+1}, \ldots, B_{r}=S_{k+r-1}$ is true, where rr is the number of digits in BB.

Samples

input1 : 101
output1 : 10
input2 : 81
output2 : 27

CS240 project Problem

Not Attended
Status
Done
Rule
IOI
Problem
5
Start at
2023-5-16 10:00
End at
2023-6-6 23:59
Duration
518 hour(s)
Host
Partic.
92