A. Helpful Maths
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.

The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count, so she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum 1+3+2+1 but she can calculate sums 1+1+2 and 3+3.

You've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can calculate the sum.

Input

The first line contains a non-empty string s — the sum Xenia needs to count. String s contains no spaces. It only contains digits and characters "+". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at most 100 characters long.

Output

Print the new sum that Xenia can count.

Examples
input
3+2+1
output
1+2+3
input
1+1+3+1+3
output
1+1+1+3+3
input
2
output
2

【代码】:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm> using namespace std; const int N=100005;
int k;
char s[110];
int a[110]; int main()
{
scanf("%s",s);
for(int i=0;i<strlen(s);i+=2)//+=2
{
a[k++]=s[i]-'0';
}
sort(a,a+k); printf("%d",a[0]);//第一个前面无+,单独输出
for(int i=1;i<k;i++)
printf("+%d",a[i]);
printf("\n");
}

  

Codeforces Round #197 (Div. 2) A. Helpful Maths【字符串/给一个连加计算式,只包含数字 1、2、3,要求重新排序,使得连加的数字从小到大】的更多相关文章

  1. 线段树 Codeforces Round #197 (Div. 2) D. Xenia and Bit Operations

    题目传送门 /* 线段树的单点更新:有一个交叉更新,若rank=1,or:rank=0,xor 详细解释:http://www.xuebuyuan.com/1154895.html */ #inclu ...

  2. Codeforces Round #197 (Div. 2) (A、B、C、D、E五题合集)

    A. Helpful Maths 题目大意 给一个连加计算式,只包含数字 1.2.3,要求重新排序,使得连加的数字从小到大 做法分析 把所有的数字记录下来,从小到大排序输出即可 参考代码 #inclu ...

  3. Codeforces Round #197 (Div. 2)

    A.Helpful Maths 分析:将读入的字符转化为数字,直接排个序就可以了. #include <cstdlib> #include <cstring> #include ...

  4. Codeforces Round #197 (Div. 2) : E

    看了codeforces上的大神写的题解之后,才知道这道题水的根本! 不过相对前面两题来说,这道题的思维要难一点: 不过想到了水的根本,这题也真心不难: 方法嘛,就像剥洋葱一样,从外面往里面剥: 所以 ...

  5. [置顶] Codeforces Round #197 (Div. 2)(完全)

    http://codeforces.com/contest/339/ 这场正是水题大放送,在家晚上限制,赛后做了虚拟比赛 A,B 乱搞水题 C 我是贪心过的,枚举一下第一个拿的,然后选使差值最小的那个 ...

  6. Codeforces Round #287 (Div. 2) D. The Maths Lecture [数位dp]

    传送门 D. The Maths Lecture time limit per test 1 second memory limit per test 256 megabytes input stan ...

  7. Codeforces Round #197 (Div. 2) C,D两题

    开了个小号做,C题一开始看错范围,D题看了半小时才看懂,居然也升到了div1,囧. C - Xenia and Weights 给出一串字符串,第i位如果是1的话,表示有重量为i的砝码,如果有该种砝码 ...

  8. Codeforces Round #197 (Div. 2) : C

    哎....这次的比赛被安叔骂的好惨! 不行呢,要虐回来: 这道搜索,老是写错,蛋疼啊! 果然是基础没打好! #include<cstdio> using namespace std; ], ...

  9. Codeforces Round #197 (Div. 2) : D

    这题也是一个线段树的水题: 不过开始题目没看明白,害得我敲了一个好复杂的程序.蛋疼啊.... 最后十几分钟的时候突然领悟到了题意,但是还是漏掉一个细节,老是过不去... 以后比赛的时候不喝啤酒了,再也 ...

随机推荐

  1. 7.Spring切入点的表达式和通知类型

    1.切入点的表达式 表达式格式: execution([修饰符] 返回值类型 包名.类名.方法名(参数)) 其他的代替: <!-- 完全指定一个方法 --> <!-- <aop ...

  2. LUOGU P1903 [国家集训队]数颜色 / 维护队列

    传送门 解题思路 带修莫队,第一次写,其实和普通莫队差不多,就是多了个时间轴,块分n^(2/3)最优,时间复杂度O(n^(5/3)). #include<iostream> #includ ...

  3. 2019-2019-2-20175332-实验三《敏捷开发与XP实践》实验报告

    一.编码标准 题目要求: 在IDEA中使用工具(Code->Reformate Code)把下面代码重新格式化,再研究一下Code菜单,找出一项让自己感觉最好用的功能. 实验步骤 1.安装ali ...

  4. 【DM642学习笔记十】DSP优化记录

    1. 处理的数据先EDMA到片内,具有更高的效率! 以YUV2RGB为例: #pragma DATA_SECTION(onchipBuf0_y,".INTPROCBUFF"); # ...

  5. 木卯先生的笔记---Object类

    1.简介 Object类是在 java.lang 包下的一个类,它是所有类的父类(也就是所有类都是Object类的子类,如果定义一个类的时候,没有指定继承的类,默认的就是继承Object类),所以Ob ...

  6. 在VS中编译Opencascade6.6.0

    话说,OpenCASCADE团队真的很给力,版本更新速度也是嗖嗖地.依稀记得上次编译OCC,那时候的第三方库.OCC本身几何引擎库,全都得自己编译. 于是,编译过程之艰苦也就可想而知了.最近重换系统, ...

  7. service network restart 报错重启失败

    Job for network.service failed because the control process exited with error code. See “systemctl st ...

  8. spring入门案例分析及原理

    Springmvc执行原理: 一. 入门案例的执行流程 1. 当启动Tomcat服务器的时候,因为配置了load-on-startup标签,所以会创建DispatcherServlet对象,就会加载s ...

  9. 通过游戏学python 3.6 第一季 第四章 实例项目 猜数字游戏--核心代码--猜测次数--随机函数和屏蔽错误代码--优化代码及注释 可复制直接使用 娱乐 可封装 函数

    #猜数字--核心代码--猜测次数--随机函数和屏蔽错误代码---优化代码及注释 #!usr/bin/env python #-*-coding:utf-8-*- #QQ124111294 import ...

  10. Linux下perl模块安装

    perl模块下载地址: http://search.cpan.org/ 假设放在/usr/local/src/下 cd /usr/local/src 上传下载的压缩包CGI-Session-3.95. ...