Codeforces Round #549 (Div. 2)B. Nirvana
1 second
256 megabytes
standard input
standard output
Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.
Help Kurt find the maximum possible product of digits among all integers from 11 to nn.
The only input line contains the integer nn (1≤n≤2⋅1091≤n≤2⋅109).
Print the maximum product of digits among all integers from 11 to nn.
390
216
7
7
1000000000
387420489
In the first example the maximum product is achieved for 389389 (the product of digits is 3⋅8⋅9=2163⋅8⋅9=216).
In the second example the maximum product is achieved for 77 (the product of digits is 77).
In the third example the maximum product is achieved for 999999999999999999 (the product of digits is 99=38742048999=387420489).
解题思路:这道题就是给你一个n数,问你1到n之间哪个数能使各个位数相乘最大;
首先我们想到尽量将每一位变为9,然后每次都向前借一位来减。
注意当K为0时,表示前面的数字没了,所以应该返回1。
代码如下:
#include<iostream>
#include<cmath>
using namespace std;
int n ;
int cj(int k)
{
if(k==)
return ;
if(k<)
{
return k;
} return max(cj(k/)*(k%),cj(k/-)*); }
int main()
{
cin>>n;
cout<<cj(n);
return ;
}
Codeforces Round #549 (Div. 2)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 ...
- Codeforces Round #549 (Div. 1)
今天试图用typora写题解 真开心 参考 你会发现有很多都是参考的..zblzbl Codeforces Round #549 (Div. 1) 最近脑子不行啦 需要cf来缓解一下 A. The B ...
- 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) 训练实录 (5/6)
The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全 ...
- CodeForces Round #549 Div.2
A. The Doors 代码: #include <bits/stdc++.h> using namespace std; ; int N; , One = ; int a[maxn], ...
- [ 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) Solution
传送门 A.The Doors 看懂题目就会写的题 给一个 $01$ 序列,找到最早的位置使得 $0$ 或 $1$ 已经全部出现 #include<iostream> #include&l ...
- 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的 ...
随机推荐
- C#中使用OracleTransaction
1. OracleTransaction类的概述(from msdn ) 应用程序通过针对OracleConnection对象调用 BeginTransaction 来创建OracleT ...
- FreeSWITCH 使用SSL-WebSocket-WebRTC
阿里上买的域名, 申请了个免费ssl, 然后开始折腾,,,, 申请了ssl证书, 但是不提供 .pem 格式的下载(*/ω\*) 然后 把一堆 提供的 都下载下来了, 然后 又到网上 搜 crt/c ...
- Xbuild
https://github.com/zhuayi/xbuild
- 第十一条理解objc_masgSend的作用
Objetive-C最基本的的东西就是它的消息机制.Objective-C运行时的最基本的东西就是 objc_msgSend, 它就是负责发送一个消息给对象的C函数. 当你写下面这样的代码时: ...
- 深入理解mysql的隔离级别
建表插入测试数据A> create table test(id int ,num int) ;Query OK, 0 rows affected (0.53 sec) A> insert ...
- ServiceStack.redis用法
using System; using System.Collections.Generic; using ServiceStack.Redis; namespace SysBuild { class ...
- RotbotFrameWork接口测试
一.添加接口测试Library 二.参数说明 三.关键字使用说明 Set Varibae: 参数化接口地址 Connect To Databse Using Custom Param: 连接数据库(需 ...
- Python下Pip的安装【get-pip】
1.下载 下载https://bootstrap.pypa.io/get-pip.py 如果不能下载,可下载:http://files.cnblogs.com/files/zhangzhiming/g ...
- leetcode - 3、Longest Substring Without Repeating Characters
题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ 题目要求: ...
- jQuery自动截取文字长度,超过部分
<html> <head> <meta charset="utf-8"> <script src="js/jqu ...