---恢复内容开始---

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 nn (1≤n≤2⋅109).

Output

Print the maximum product of digits among all integers from 1 to n.

Examples
Input

Copy
390
Output

Copy
216
Input

Copy
7
Output

Copy
7
Input

Copy
1000000000
Output

Copy
387420489
Note

In the first example the maximum product is achieved for 389389 (the product of digits is 3⋅8⋅9=216).

In the second example the maximum product is achieved for 77 (the product of digits is 7).

In the third example the maximum product is achieved for 99999999 (the product of digits is 99=38742048999).

题意:给出n,找出不大于n的一个数,试其乘积最大。

思路:对于一个位置上的数,①可以保持不变,②可以使其变成9,前置位-1.

这样我们可以递归枚举。

 #include<bits/stdc++.h>
using namespace std; int n; int cal(int n)
{
if(n == )return ;
else if(n < )return n;
else
{
return max(cal(n/)*(n%),cal(n/-)*);
}
} int main()
{
scanf("%d",&n);
printf("%d\n",cal(n));
}

---恢复内容结束---

B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)的更多相关文章

  1. [题解] Codeforces Round #549 (Div. 2) B. Nirvana

    Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...

  2. Codeforces Round #549 (Div. 1)

    今天试图用typora写题解 真开心 参考 你会发现有很多都是参考的..zblzbl Codeforces Round #549 (Div. 1) 最近脑子不行啦 需要cf来缓解一下 A. The B ...

  3. Codeforces Round #549 (Div. 2)B. Nirvana

    B. Nirvana time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  4. Codeforces Round #549 (Div. 2) 训练实录 (5/6)

    The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全 ...

  5. CodeForces Round #549 Div.2

    A. The Doors 代码: #include <bits/stdc++.h> using namespace std; ; int N; , One = ; int a[maxn], ...

  6. [ Codeforces Round #549 (Div. 2)][D. The Beatles][exgcd]

    https://codeforces.com/contest/1143/problem/D D. The Beatles time limit per test 1 second memory lim ...

  7. Codeforces Round #549 (Div. 2) Solution

    传送门 A.The Doors 看懂题目就会写的题 给一个 $01$ 序列,找到最早的位置使得 $0$ 或 $1$ 已经全部出现 #include<iostream> #include&l ...

  8. Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)

    https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...

  9. Codeforces Round #549 (Div. 2) E 倍增处理按排列顺序的上一个位置

    https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的 ...

随机推荐

  1. 爬虫,基于request,bs4 的简单实例整合

    简单爬虫示例 爬取抽屉,以及自动登陆抽屉点赞 先查看首页拿到cookie,然后登陆要携带首页拿到的 cookie 才可以通过验证 """""" ...

  2. 安卓微信连接fiddler等抓包工具无法抓取https

    问题描述: 在手机连接pc的fiddler后,安卓微信打不开https页面,安卓的浏览器.qq等都可以正常访问https,ios也都可以,就只有安卓微信放问https是空白页面 解决思路: 一. 证书 ...

  3. 洛谷P1072 Hankson 的趣味题(题解)

    https://www.luogu.org/problemnew/show/P1072(题目传送) 数学的推理在编程的体现越来越明显了.(本人嘀咕) 首先,我们知道这两个等式: (a0,x)=a1,[ ...

  4. Ubuntu18.04 安装32bit库后出现问题

    ERROR: ld.so: object 'libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (cannot open shared ob ...

  5. Vue(小案例_vue+axios仿手机app)_图片列表操作

    一.前言 1.让图片还没有被完全加载出来的时候给用户提示                                       2.图片查看器 二.主要内容 1.让图片还没有被完全加载出来的时候 ...

  6. 微信小程序之canvas 文字断行和省略号显示

    文字的多行处理在dom元素中很好办.但是canvas中没有提供方法,只有通过截取指定字符串来达到目的. 那么下面就介绍我自己处理的办法: wxml: <canvas canvas-id='wor ...

  7. css 选择器符号

    1. 空格 —— “后代选择器” 例如下面这个例子,表示div元素里面所有的p元素 div p { ... } 2. > —— “子选择器” 例如下面这个例子,表示div元素里面所有的子代(不含 ...

  8. Jenkins-在windows上配置自动化部署(Jenkins+Bonobo.Git.Server)

    本文配置Jenkins.git服务器采用 Bonobo.Git.Server 1. 登录后,打开Jenkins界面,新建一个任务 2. 配置信息 3. 配置git项目地址,我们先进行其他配置,等会再继 ...

  9. java 为什么wait(),notify(),notifyAll()必须在同步(Synchronized)方法/代码块中调用?

    wait()作用:该方法用来将当前线程置入休眠状态,直到接到通知或被中断为止.条件:在调用wait()之前,线程必须要获得该对象的对象级别锁,即只能在同步方法或同步块中调用wait()方法.进入wai ...

  10. Jsp1

    jsp代码中包含两类:jsp元素和template data. template模板 data:jsp引擎不处理的部分,就是<%....%>之外的部分,直接给浏览器显示. <%! % ...