#include <string>
#include <iostream>
using namespace std; class SwappingDigits
{
public:
bool notBiggest(string &s,int pos)
{
int len=s.length();
int i=;
for (i=pos+;i<len;i++)
{
if (s[i]<s[pos]&&(s[i]!=''||pos!=))
{
return true;
}
}
return false;
}
int findSmallest(string&s,int pos)
{
int len=s.length();
int i=;
char c='';
int index;
for (i=len-;i>pos;i--)
{
if (s[i]<c&&(s[i]!=''||pos!=))
{
c=s[i];
index=i;
}
}
return index;
}
string minNumber(string num)
{
int i;
int len=num.length();
for (i=;i<len-;i++)
{
if (notBiggest(num,i))
{
int index=findSmallest(num,i);
char c=num[index];
num[index]=num[i];
num[i]=c;
break;
}
}
return num;
}
};
int main()
{
SwappingDigits sol;
string s;
while(true)
{
cin>>s;
cout<<sol.minNumber(s)<<endl;
}
}

Topcoder SRM583 DIV 2 250的更多相关文章

  1. Topcoder SRM 643 Div1 250<peter_pan>

    Topcoder SRM 643 Div1 250 Problem 给一个整数N,再给一个vector<long long>v; N可以表示成若干个素数的乘积,N=p0*p1*p2*... ...

  2. Topcoder SRM 656 (Div.1) 250 RandomPancakeStack - 概率+记忆化搜索

    最近连续三次TC爆零了,,,我的心好痛. 不知怎么想的,这题把题意理解成,第一次选择j,第二次选择i后,只能从1~i-1.i+1~j找,其实还可以从j+1~n中找,只要没有被选中过就行... [题意] ...

  3. TopCoder SRM 596 DIV 1 250

    body { font-family: Monospaced; font-size: 12pt } pre { font-family: Monospaced; font-size: 12pt } P ...

  4. 【topcoder SRM 702 DIV 2 250】TestTaking

    Problem Statement Recently, Alice had to take a test. The test consisted of a sequence of true/false ...

  5. Topcoder SRM 661 (Div.1) 250 MissingLCM - 数论

    [题意] 给你一个数N(1<=N<=10^6),要求最小的M(M>N),使得lcm(n+1,n+2,...m)=lcm(1,2,3,...,m) [思路] 手速太慢啦,等敲完代码的时 ...

  6. topcoder srm 628 div2 250 500

    做了一道题,对了,但是还是掉分了. 第二道题也做了,但是没有交上,不知道对错. 后来交上以后发现少判断了一个条件,改过之后就对了. 第一道题爆搜的,有点麻烦了,其实几行代码就行. 250贴代码: #i ...

  7. SRM 719 Div 1 250 500

    250: 题目大意: 在一个N行无限大的网格图里,每经过一个格子都要付出一定的代价.同一行的每个格子代价相同. 给出起点和终点,求从起点到终点的付出的最少代价. 思路: 最优方案肯定是从起点沿竖直方向 ...

  8. 竞赛图的得分序列 (SRM 717 div 1 250)

    SRM 717 DIV 1 中 出了这样一道题: 竞赛图就是把一个无向完全图的边定向后得到的有向图,得分序列就是每个点的出度构成的序列. 给出一个合法的竞赛图出度序列, 要求构造出原图(原题是求(u, ...

  9. TopCoder[SRM513 DIV 1]:Reflections(1000)

    Problem Statement      Manao is playing a new game called Reflections. The goal of the game is trans ...

随机推荐

  1. 如何用openvr api打开vive前置摄像头

    随着越来越多的开发者开始他们的VR开发工作,他们看到了这项技术的巨大潜力,像是Valve这样的公司正在想办法保证他们的软件开发包(SDK)能够提供尽量多的功能.今天这家公司发布了其针对SteamVR的 ...

  2. Xamarin 编程之打电话

    参考:http://www.cnblogs.com/yaozhenfa/ Main.axml <?xml version="1.0" encoding="utf-8 ...

  3. Webstorm的序列号和证书

    User Name: ------------name-------------- EMBRACE -------------name-------------- License Key: ===== ...

  4. paper 113:Bhattacharyya distance

    在统计理论中,Bhattacharyya距离用来度量两个离散或连续概率分布的相似性.它与Bhattacharyya系数(Bhattacharyya coefficient)高度相关,后者是用来度量两个 ...

  5. 【转】SVN管理多个项目版本库

    转载地址:http://blog.163.com/zhangxuemin_zy/blog/static/10178565520115704031799/ SVN管理多个项目版本库:   安装SVN服务 ...

  6. js 多少天以后的时间

    /** * 多少天以后的时间 * @param date 时间 * @param num 多少天 * @param type 类型 年 月 天(默认天) */ exports.afterDate = ...

  7. 20160308001 GridView的Sorting排序

    参考地址: http://www.cnblogs.com/yinluhui0229/archive/2011/08/01/2124169.html 功能介绍:单击gridview的某一列列头,可以对该 ...

  8. SDUTOJ 3312

    题目描述 给出一个n*n的矩阵,矩阵中只有0和1,现在有两种操作: 1 x y 将第x行第y列的数字改变(0变1,1变0) 2 x1 y1 x2 y2求由左上角(x1,y1)到右下角(x2,y2)组成 ...

  9. windows消息和消息队列

    windows消息和消息队列 转自:http://blog.163.com/zhangjie_0303/blog/static/990827062010113062446767/ 与基于MS - DO ...

  10. python异常和错误(syntax errors 和 exceptions)

    语法错误 语法错误又被称解析错误 >>> for i in range(1..10):print(i) File "<stdin>", line 1 ...