码迷,mamicode.com
首页 > 其他好文 > 详细

洛咕P1106

时间:2019-08-18 21:19:58      阅读:55      评论:0      收藏:0      [点我收藏+]

标签:mmm   收获   space   for   string   include   clu   表示   org   

//贪心思路:找降序对
//其实主要的收获是知道了string的妙用!(呸

#include<bits/stdc++.h> using namespace std; const int N = 256; string ss; int k; int main() { cin>>ss>>k; int n=ss.length(); for(int i=0;i<k;i++) for(int j=0;j<n;j++){ if((int)ss[j]>(int)ss[j+1]){ //string真的流弊!原来真的可以直接表示字符串的某一位……emmmm我太菜了 ss=ss.substr(0, j)+ss.substr(j + 1,n - j); break; } } stringstream tr; int b; tr<<ss; tr>>b; //最后这一波输入流操作是为了防止删数后首位出现0 cout<<b; }

来源:https://www.luogu.org/problem/P1106

洛咕P1106

标签:mmm   收获   space   for   string   include   clu   表示   org   

原文地址:https://www.cnblogs.com/phemiku/p/11373709.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!