Saturday, June 28, 2014

Codeforces Round #197 (Div. 2), problem: (A) Helpful Maths solution

Codeforces Round #197 (Div. 2), problem: (A) Helpful Maths: http://codeforces.com/problemset/problem/339/A

Codeforces Round #197 (Div. 2), problem: (A) Helpful Maths editorial: http://codeforces.com/blog/entry/8725

Codeforces Round #197 (Div. 2), problem: (A) Helpful Maths solution: http://ideone.com/xQMWrd

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
    int a[105], n;
    char s[105];
    scanf("%s", s);
    for(int i=0, j=0; i<strlen(s); i+=2, j++) a[j]=s[i]-48, n=j;
    n++;
    sort(a, a+n);
    for(int i=0; i<n-1; i++) printf("%d+", a[i]);
    printf("%d", a[n-1]);
    return 0;
}

note: char - 48, because look at ascii codes

No comments:

Post a Comment