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为起始位 ...
随机推荐
- ue4 材质表达式分类
绿色节点 颜色 Color Desaturation 数学 Math GO 字体 Font FontSample,FontSampleParameter 实用程序 Utility 常用: Desatu ...
- 获取reporting services导出pdf的url的方法
public static string genRptUrl(string strRptServer, string strRptPath, string strRptName, ParameterV ...
- input(type="checkbox"|type="radio")+jquery使用
1.用.is(":checked")判断input是否为选中状态 例: var value=$(this).is(":checked"); localStora ...
- C# - 多线程(基础)
多线程 基础(Multithreading) 一些基本的关于线程和与其相关的概念 位)的变量赋值,这个操作就是原子性的.因为它可以一次性填充64位的二进制数据到栈上,属于一步完成,不会发生断裂.而假如 ...
- win10设置vscode的终端为管理员权限
右击vscode 点击属性选择兼容性,勾选 “以管理员身份运行此程序” 确定即可!
- 肺结节CT影像特征提取(四)——肺结节CT影像特征提取MATLAB代码实现
之前的文章讲述了肺结节CT影像数据特征提取算法及基于MATLAB GUI设计的肺结节CT影像特征提取系统.本文将讲述几个主要部分的代码实现,分别是预处理.灰度特征提取.纹理特征提取.形态特征提取数据. ...
- 使用Python进行OCR -- 识别图片中的文字
工具 Tesseract pytesseract tesserocr 朋友需要一个工具,将图片中的文字提取出来.我帮他在网上找了一些OCR的应用,都不好用.所以准备自己研究,写一个Web APP供他使 ...
- 我实在不懂Python的Asyncio
原语 事件循环(Event Loop) Awaitables和Coroutines Coroutine Wrappers Awaitables and Futures Tasks Handles Ex ...
- sublime自动保存设置
首选项——用户设置 (Preferences:Settings - User) 行末添加"save_on_focus_lost": true 注意用逗号分隔 保存即可 save_o ...
- CentOS6配置Taiga
背景 企业项目管理是一个比较复杂的事情,这个市场需求非常大,目前市面上也存在着teambition,tower等平台,但是这些工具平台目前都是付费才能有完整的功能,免费版根本不能满足团队的需求.一番调 ...