問題一覧 > 通常問題

No.1472 Contrived Sum

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 140
作問者 : SnaKeijiji / テスター : first_vil nok0
お気に入りにしたユーザー ProblemId : 6104 / 自分の提出
問題文最終更新日: 2021-04-10 00:22:23
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 290 (順位表) の他の問題:

Problem Statement

For a positive integer $n$, let $S(n)$ denote the sum of the digits of $n$ written in decimal notation. For example, $S(103)=1+0+3=4$.
You are given a non-negative integer $N$.
Over all pairs of integers $A,B$ satisfying $1\le A\le B<\pi \times 10^N$ (where $\pi$ denotes the circle constant), find the maximum value of $S(A\times B)$. Also, find how many distinct values of $A\times B$ attain the maximum value of $S(A\times B)$.

Input

$N$

  • $0\le N\le 10^8$
  • $N$ is an integer

Output

Output the maximum value of $S(A\times B)$ and the number of distinct values of $A\times B$ at which $S(A\times B)$ attains its maximum, separated by a space.
Print a newline at the end.

Sample

Sample 1
Input
0
Output
9 1

Since $1\le A\le B<\pi \times 10^0=3.141592\dots$, the possible pairs $A,B$ are the $6$ pairs $(A,B)=(1,1)(1,2)(1,3)(2,2)(2,3)(3,3)$.
The respective values of $S(A\times B)$ are $1,2,3,4,6,9$, so the maximum value of $S(A\times B)$ is $9$. Also, the only value of $A\times B$ for which $S(A\times B)$ attains the maximum value $9$ is $9$, so there is $1$ kind.
(Besides $9$, values of $A\times B$ such as $18$ and $135$ would also make $S(A\times B)$ equal to $9$, but such values do not occur under the constraints on $A,B$ here.)

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。