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为起始位 ...
随机推荐
- PYthon3:简单几步实现冒泡排序
1.概念理解: 冒泡排序:可以简单的理解为是列表中相近的元素,两两比较,小的在前面.最多需要len()-1次排序. 2.例子:a=[11,7,4,56,35,0] 3.代码实现: 4.输出结果: 第1 ...
- git切换到新的远程地址
查看仓库链接 git remote -v 修改url链接 git remote set-url origin URL
- 集合-Collections工具
1.定义 Collections是集合类的一个工具类,它提供了一系列静态方法用于对容器中的元素进行排序和搜索等一系列操作. 注:Collection是一个集合接口,而Collections是一个有着操 ...
- 微信小程序scroll-view(或者其他view) 计算高度 px转rpx有关
wx.getSystemInfo({ success: function (res) { that.globalData.winWidth = res.windowWidth; that.global ...
- flask 搭建ssl接口
from flask import Flask,jsonifyapp = Flask(__name__)#app.config['SERVER_NAME'] = 'example.com' @app. ...
- 【转】HashMap集合中key只能为引用数据类型,不能为基本类型
在HashMap中,为什么不能使用基本数据类型作为key? 其实和HashMap底层的存储原理有关,HashMap存储数据的特点是:无序.无索引.不能存储重复元素. 存储元素采用的是hash表存储数据 ...
- 《剑指offer》把数组排成最小的数
本题来自<剑指offer> 反转链表 题目: 思路: C++ Code: Python Code: 总结:
- rsync 安装
#!/bin/bash #root running ] then echo "must is root running" exit fi if [ -e /etc/rsyncd.c ...
- fft,ntt
在被两题卡了常数之后,花了很久优化了自己的模板 现在的一般来说任意模数求逆1s跑3e5,exp跑1e5是没啥问题的(自己电脑,可能比luogu慢一倍) 当模数是$998244353,100453580 ...
- SQL反模式学习笔记22 伪键洁癖,整理数据
目标:整理数据,使不连续的主键Id数据记录变的连续. 反模式:填充断档的数据空缺. 1.不按照顺序分配编号 在插入新行时,通过遍历表,找到的第一个未分配的主键编号分配给新行,来代替原来自动分配的伪主键 ...