当前位置:网站首页>OJ 1507 deletion problem
OJ 1507 deletion problem
2022-07-28 06:38:00 【JETECHO】
describe
Enter a high precision positive integer n(<=240 position ),
Remove any s The remaining numbers after the first number will form a new integer in the original left-right order .
Programming for a given n and s, Look for a solution , Minimize the remaining number .
Input
first line : The length is n The positive integer
The second line : Number of numbers to delete s
Output
The minimum number remaining after deletion
sample input 1
178543
4
sample output 1
13
The title requires deleting some data to achieve the minimum number after deletion , That is to delete the maximum value in a continuous non descending order every time , Why not in descending order , Because it's possible There is only one data in the whole sequence , This is in descending order compared with the following , At this time, delete the first data in descending order , It's similar. In fact, this is an ascending order of data .
#include <iostream>
#include <string>
using namespace std;
int main()
{
string n;
int a;
while(cin>>n>>a)
{
while(a--)
{
int i=0;
while(n[i]<=n[i+1])
i++;
n.erase(i,1);
}
int i=0;
for(i;i<n.size();i++)
if(n[i]!='0')
break;
for(i;i<n.size();i++)
cout<<n[i];
cout<<endl;
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Redhawk Dynamic Analysis
C语言的编译和预处理
二维数组实战:螺旋矩阵
2022年七夕礼物推荐!好看便宜又实用的礼物推荐
[PTA----输出全排列]
2021-11-10
[c语言]简易通讯录的实现
Treasure plan TPC system development DAPP construction
Getting started with hugging face
2022-05-24 use of spiel
[PTA--利用队列解决猴子选大王问题】
OJ 1089 春运
Several methods of QT setting loading interface
Leetcode 刷题日记 剑指 Offer II 050. 向下的路径节点之和
刷题记录----二叉树
[哈希表基础知识]
动态规划--多步爬楼梯(爬楼梯进阶版)
2022-07-19 Damon database connection instance, execution script, system command
江中ACM新生10月26日习题题解
开放式耳机推荐哪款最好、性价比最高的开放式耳机








