#P8771. Nine-ary to Decimal Conversion and Straight Date Counting

    ID: 21935 Type: Default 1000ms 256MiB

Nine-ary to Decimal Conversion and Straight Date Counting

Nine-ary to Decimal Conversion and Straight Date Counting

Problem A: Nine-ary to Decimal Conversion

Convert the base-9 positive integer \((2022)_9\) to its decimal (base-10) equivalent.

Recall that when converting a number from base \(b\) to base 10, the value is \(d_n\times b^n + d_{n-1}\times b^{n-1} + \cdots + d_0\).


Problem B: Straight Date Counting

A "straight" refers to three consecutive digits (for example, \(123\), \(456\), etc.). A straight date is defined as a date, in the format \(yyyyMMdd\), which contains at least one occurrence of three consecutive digits in increasing order. For instance, the date \(20220123\) is considered a straight date because it contains the sequence \(123\), whereas \(20221023\) is not.

Determine the total number of straight dates in the year 2022.

inputFormat

This problem does not require any input. The program should output the answers directly.

outputFormat

The program should output two lines:

  • The first line contains the decimal conversion result for Problem A.
  • The second line contains the number of straight dates for Problem B.

sample

1478

14

</p>