题目

解决思路是,每个位上都是9的情况,遍历一下就可以了。

#include <iostream>

using namespace std;

int n;
int a[35];
int main()
{
scanf("%d",&n); int tag=0;
while(n)
{
a[tag]=n%10;
n=n/10;
tag++;
} int x=1;
for(int i=0;i<tag;i++)
{
x =x*a[i];
} for(int i=0;i<tag-1;i++)
{
if(a[i]!=9)
{
a[i]=9;
int pos=i+1;
a[pos]--;
while(pos<tag&&a[pos]==-1)
{
a[pos]=9;
pos++;
a[pos]--;
}
}
int y=1;
for(int j=0;j<tag;j++)
{
if(a[j]==0) continue;
y=y*a[j];
} x = max(x,y);
}
printf("%d\n",x); }

CodeForces 1143 B. Nirvana的更多相关文章

  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. B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)

    ---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...

  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 div2 1143-B Nirvana 题解

    Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater v ...

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

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

  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) F 数形结合 + 凸包(新坑)

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

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

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

  9. Codeforces Round #549 (Div. 2) D 数学

    https://codeforces.com/contest/1143/problem/D 题意 有nk个城市,第1,k+1,2k+1,...,(n-1)k+1城市有餐厅,你每次能走l距离,a为起始位 ...

随机推荐

  1. 后台挂载/卸载程序[Linux/Windows]

    后台挂载应用程序 即使关闭掉控制台窗口,该程序的进程也将会一直运行下去 #Windows 1.编写bat命令文件[形如:a.bat] 2.cmd执行:start /b a.bat #Linux noh ...

  2. 如何使用AB PLC仿真软件Studio 5000 Logix Emulate

    前言:在学习PLC编程或程序开发过程中,如果身边没有实体PLC,又想验证程序逻辑,这时,仿真软件是不错的选择.针对AB PLC的仿真软件Studio 5000 Logix Emulate,有的同学说: ...

  3. C语言之路-2-判断

    #include<stdio.h> int main() { ; printf("请输入"); scanf("%d",&a); ){ pri ...

  4. UML各种图总结-精华

    UML(Unified Modeling Language)是一种统一建模语言,为面向对象开发系统的产品进行说明.可视化.和编制文档的一种标准语言.下面将对UML的九种图+包图的基本概念进行介绍以及各 ...

  5. HTTP协议10-实体首部字段

    实体首部字段 实体首部字段是包含咋请求报文和响应报文中实体部分的首部,用于补充内容的更新时间等于实体相关的信息. 1)Allow Allow:GET,HEAD 用于通知客户端能够支持访问指定资源的请求 ...

  6. JS高德地图计算两地之间的实际距离

    这个是通过导航的方式来获取两地之间的实际距离,和消耗的时间(key值自己去申请哈) <!doctype html> <html> <head> <meta c ...

  7. H5新特性之data-*

    简单介绍:html5的data-*能够为标签添加一些自定义的属性和值,并且这种自定义的属性和值可以通过js来获取,十分的便捷 代码: //html<tr th:each="plan : ...

  8. 数据表为null的字段添加默认值

    UPDATE im_clusters SET `location`='深圳会展中心' WHERE `location` is NULL

  9. iOS开发之#impor与#include的区别

    #import比起#include的好处就是不会引起交叉编译 在 Objective-C中,#import 被当成 #include 指令的改良版本来使用.除此之外,#import 确定一个文件只能被 ...

  10. OpenSSL 提取 pfx 数字证书公钥与私钥

    由于之前生产环境已经使用了 Identityserver4 用来做授权与认证的服务,而新项目采用 Spring Cloud 微服务体系,一方面 Spring Cloud 官方暂时只支持 OAuth2. ...