View Code of Problem 609

#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
int main()
{
	string s;
	
	long long n;
	while (cin >> s >> n)
	{
		//s = s + '0';
		while (n--)
		{
			for (int i = 0;i < s.size();i++)
			{
				if (s[i] > s[i + 1])
				{
					s.erase(i, 1);
					break;
				}
			}
		}
		while (s[0] == '0')
			s.erase(0, 1);
		if (s.size() == 0)
			cout << "0" << endl;
		else
			cout << s << endl;
	}
}

Double click to view unformatted code.


Back to problem 609