from re import sub
n = int(input())
digits = len(str(n))
result = 0
for i in range(digits):
sub_result = 9 ** i
sub_n = n // (10 ** i)
remainder_n = n % (10 ** i)
should_be_reduce = False
temp_n = n
for j in range(i):
if (temp_n % 10 != 9):
should_be_reduce = True
temp_n /= 10
while (sub_n > 0):
if (should_be_reduce):
if (sub_n % 10 == 0):
sub_result *= 9
else:
should_be_reduce = False
sub_result *= max(1, ((sub_n % 10) - 1))
else:
sub_result *= ((sub_n % 10))
sub_n //= 10
if (sub_result > result):
result = sub_result
print(result)
#include <bits/stdc++.h>
using namespace std;
int solve(int n)
{
if(n<10)
{
return max(1, n);
}
return max(n%10*solve(n/10), solve(n/10-1)*9);
}
int main()
{
int n;
cin>>n;
cout<<solve(n)<<endl;
}
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |