不明白为什么每一道水题我都写的这么辛苦。
/*
ID:狂人
num:09073355
E-mail:wenboguo@live.com
*/
#include <vector>
#include <list>
#include <assert.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <fstream>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a) (int(a.size()))
#define mp make_pair
#define pb push_back
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> ii;
typedef pair<string, string>ss;
typedef long double ld;
const int INF = 0x7ffffff;
const int Maxl = 102;
//结构体内重载‘<’,使优先队列可以对其进行排序
struct Node{
string str1;
string str2;
Node(string st1, string st2):str1(st1),str2(st2){}
bool operator < (const Node &a) const
{
return a.str1 < str1;
}
};
int main(void)
{
//ifstream cin ("aaa.txt");
string str;
while(cin >> str)
{
priority_queue<int ,vector<int>, greater<int> >my_que;
//my_que.clear();
int st = 0, en = 0;
while (st < str.size())
{
int num = 0;
while (str[st] == '5') //去掉连续5的情况
{
st++;
}
for (en = st; en <= str.size(); en++){
if (en != str.size())
{
if (str[en] == '5')
{
break;
}
}
else
break;
} //如果遇到连续几个5的情况就会不行了
for (int i = st,j = en-1; i <= j; i++)
{
num *= 10;
num += str[i] - '0';
}
if (st > en-1)
{
continue;
}
my_que.push(num);
st = en + 1;
}
while(my_que.size() != 1)
{
cout << my_que.top() << " ";
my_que.pop();
}
cout << my_que.top() << endl;
}
//system("pause");
return 0;
}