题目

解决思路是,每个位上都是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. 在c:forEach与s:iterator里面使用if标签判断当前位置是否为2的倍数

    在c:forEach与s:iterator里面使用if标签判断当前位置是否为2的倍数 c:forEach: <c:forEach var="workflow" items=& ...

  2. 关于 min_25 筛的入门以及复杂度证明

    min_25 筛是由 min_25 大佬使用后普遍推广的一种新型算法,这个算法能在 \(O({n^{3\over 4}\over log~ n})\) 的复杂度内解决所有的积性函数前缀和求解问题(个人 ...

  3. ansible 使用记录

    copy: ansible server -m copy -a 'src=/etc/ansible/port/iptables dest=/etc/sysconfig/iptables owner=r ...

  4. CentOS 7 中 Systemd详解

    一.systemd的由来 Linux一直以来采用init进程但是init有两个缺点: 1.启动时间长.Init进程是串行启动,只有前一个进程启动完,才会启动下一个进程.(这也是CentOS5的主要特征 ...

  5. js的逆向解析

    过程: 知道如何寻找登录的接口 知道如何确定js的位置 知道如何观察js的执行过程 知道js的执行方法 1. 确定网站的登录的接口登录的form表单中action对应的url地址通过抓包可以发现,在这 ...

  6. freemarker是什么东西?

    前言 由于考虑到网站访问量,以及tocmat可能承受的最大访问压力,我们需要引进一些比较好的技术,来解决这个问题.所以在项目快要结束之际又收到消息,我们要考虑到这些问题然后对现在的项目进行改进,于是就 ...

  7. ansible的tests

    Ansible的tests : 路径 /usr/lib/python2.7/site-packages/ansible/plugins/test core.py # failure testing ' ...

  8. Scrapy Selectors 选择器

    0. 1.参考 <用Python写网络爬虫>——2.2 三种网页抓取方法  re / lxml / BeautifulSoup 需要注意的是,lxml在内部实现中,实际上是将CSS选择器转 ...

  9. 模块度Q

    模块度:也称模块化度量值,是目前常用的一种衡量网络社区结构强度的方法. 常用语衡量一个社区划分结果的优劣:一个理想化的社区划分应该对应着社区内部节点间相似度尽可能的高,同时社区外部节点间的相异度尽可能 ...

  10. Java模拟耗时任务异步执行

    说明:耗时任务开启单独线程处理,任务线程处理完毕通知主线程 1.回调接口定义 public interface ResponseCallBack { public void printMsg(Stri ...