Helpful Maths

简介: Helpful Maths

文章目录

一、Helpful Maths

总结


一、Helpful Maths

本题链接:Helpful Maths


题目:


A. Helpful Maths

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard 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


本博客给出本题截图:

image.png

题意:给数字从小到大排序输出,注意输出的时候每两个数之间有+

AC代码

#include <iostream>
#include <algorithm>
using namespace std;
const int N = 110, M = N / 2;
char s[N];
int num[M], cnt;
int main()
{
  scanf("%s", s);
  for (int i = 0, j = 0; s[i]; i ++ )
    if (s[i] >= '0' && s[i] <= '9')
    {
        num[j ++] = s[i] - '0';
        cnt ++;
    }
  sort(num, num + cnt);
  if (num[1] == 0)
  {
      cout << num[0] << endl;
      exit(0);
  }
  else
  {
      cout << num[0];
      for (int i = 1; i < cnt; i ++ )
          printf("+%d", num[i]);
  }
  return 0;
}

总结

水题,不解释


目录
相关文章
|
机器学习/深度学习 人工智能 算法
图解机器学习 | KNN算法及其应用
KNN算法(K近邻算法)是一种很朴实的机器学习方法,既可以做分类,也可以做回归。本文详细讲解KNN算法相关的知识,包括:核心思想、算法步骤、核心要素、缺点与改进等。
5282 1
图解机器学习 | KNN算法及其应用
|
12月前
|
机器学习/深度学习 人工智能 监控
NeurIPS 2025 Spotlight!跨模态重识别革命!东北大学等 MDReID 图像信息智能匹配
东北大学等提出MDReID,获NeurIPS 2025 Spotlight!该方法实现跨模态行人重识别,创新性地将图像特征解耦为通用与专用特征,支持RGB、NIR、TIR等任意模态自由匹配,显著提升异源图像检索精度,推动安防、监控等领域智能化发展。
586 1
NeurIPS 2025 Spotlight!跨模态重识别革命!东北大学等 MDReID 图像信息智能匹配
|
监控 编译器 Windows
Qt5实现Windows平台串口通信
Qt5实现Windows平台串口通信
|
12月前
|
人工智能 监控 数据可视化
2025 主流 BI 工具全景盘点——10款国内外产品赋能企业决策
2025年BI工具迎来AI驱动新阶段,市场规模持续扩张。本文盘点10款主流产品,涵盖瓴羊Quick BI、Power BI、Tableau等,聚焦AI交互、行业适配与生态集成三大趋势,解析各工具核心技术与场景价值,助力企业精准选型,赋能数字化决策升级。Quick BI(阿里云旗下)核心优势:国内唯一连续 6 年入选 Gartner ABI 魔力象限的智能 BI 产品;搭载智能小Q多Agent协同分析功能,中文语义识别准确率达 98%。
1044 12
|
Linux iOS开发 芯片
Blender 5.0 发布 - 开源 3D 创意软件 (渲染 建模 雕刻)
Blender 5.0 (Linux, macOS, Windows) - 开源 3D 创意软件 (渲染 建模 雕刻)
935 0
Blender 5.0 发布 - 开源 3D 创意软件 (渲染 建模 雕刻)
|
Ubuntu Python
Ubuntu 安装Python3.8
Ubuntu 安装Python3.8
1808 0
|
缓存 监控 安全
基于Django的电商项目的设计与实现
基于Django的电商项目的设计与实现
1573 0
|
数据可视化 数据处理 开发者
构建高效的数据流图:Python与PyGraphviz的实践
【9月更文挑战第13天】在本文中,我们将探索如何利用Python和PyGraphviz库来创建和操作数据流图。我们将通过一个具体示例,展示如何从零开始构建一张数据流图,并讨论如何优化图表以提高可读性。文章旨在为初学者提供一个清晰的入门指南,同时为有经验的开发者提供一些高级技巧。
|
存储 缓存 固态存储
|
自然语言处理 监控 搜索推荐
《百炼成金-大金融模型新篇章》––12.应用场景与技术架构选型(1)
百炼必定成金,新质生产力会催生新质劳动力,谨以此文抛砖引玉,希望与业内的各位朋友一同探讨如何积极拥抱并运用大模型技术,以应对和驾驭不断变化的市场环境,实现科技金融持续稳定的提质增效和创新发展,携手开启金融大模型未来新篇章。
921 1