CodeForces 1143 B. Nirvana
解决思路是,每个位上都是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的更多相关文章
- [题解] Codeforces Round #549 (Div. 2) B. Nirvana
Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...
- B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)
---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...
- 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 ...
- 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 ...
- Codeforces Round #549 (Div. 2) 训练实录 (5/6)
The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全 ...
- [ 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 ...
- Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)
https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...
- Codeforces Round #549 (Div. 2) E 倍增处理按排列顺序的上一个位置
https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的 ...
- 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为起始位 ...
随机推荐
- luogu P5293 [HNOI2019]白兔之舞
传送门 关于这题答案,因为在所有行,往后跳到任意一行的\(w_{i,j}\)都是一样的,所以可以算出跳\(x\)步的答案然后乘上\(\binom{l}{x}\),也就是枚举跳到了哪些行 如果记跳x步的 ...
- tp5入门
runtime目录里的文件是临时文件,可随时删除 在tp5里,命名空间对应了文件的所在目录,app命名空间通常代表了文件的起始目录为application,而think命名空间则代表了文件的起始目录为 ...
- dos.orm
引言: Dos.ORM(原Hxj.Data)于2009年发布.2015年正式开源,该组件已在数百个成熟项目中应用,是目前国内用户量最大.最活跃.最完善的国产ORM.初期开发过程中参考了NBear与My ...
- JS基础之传参(值传递、对象传递)
一.概念 我们需了解什么是按值传递(call by value),什么是按引用传递(call by reference).在计算机科学里,这个部分叫求值策略(Evaluation Strategy). ...
- nginx php-fpm开启session
一. 权限问题,这个是发生在多数情况下 找到php session目录设置给 nginx 或者 apache最大权限 二. 配置问题按如下就没啥问题了 [Session] session.save ...
- 六.ansible批量管理服务
期中集群架构-第六章-ansible批量管理服务介绍====================================================================== 01. ...
- Bootstrap-datepicker3官方文档中文翻译---概述(原文链接 http://bootstrap-datepicker.readthedocs.io/en/latest/index.html)
bootstrap-datepicker Bootstrap-datepicker 提供了一个拥有Bootstrap样式的弹性Datepicker控件 Requirements/使用要求 Bootst ...
- 【winform】userControl刷新父窗体的datagridview
1.ContextMenuStrip 获取右键控件名称 this.contextMenuScriptScore.SourceControl.Name; //当前控件名 2.radiobutton 分组 ...
- 03.Regression
01.regression # -*- coding: utf-8 -*- """ scipy 패키지 선형 회귀분석 """ from s ...
- day16匿名函数
匿名函数,好像也就是 lambda 表达式 先来看一段函数,返回 def func(n): return n * 3 print(func(5))15 用lambda表达式写: func = lamb ...