Codeforces Round 549 (Div. 2)
翻译中…
Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.
翻译中…
Help Kurt find the maximum possible product of digits among all integers from $1$ to $n$.
翻译中…
Input
翻译中…
The only input line contains the integer $n$ ($1 \le n \le 2\cdot10^9$).
翻译中…
Output
翻译中…
Print the maximum product of digits among all integers from $1$ to $n$.
翻译中…
Note
翻译中…
In the first example the maximum product is achieved for $389$ (the product of digits is $3\cdot8\cdot9=216$).
翻译中…
In the second example the maximum product is achieved for $7$ (the product of digits is $7$).
翻译中…
In the third example the maximum product is achieved for $999999999$ (the product of digits is $9^9=387420489$).
翻译中…
样例
Input #1
390
Output #1
216
InputCopy
OutputCopy
Input #2
7
Output #2
7
InputCopy
OutputCopy
Input #3
1000000000
Output #3
387420489
InputCopy
OutputCopy
题目信息
标签
暴力
数学
数论
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。