백준/백준-C++

10610번: 30

Beabletoet 2017. 6. 13. 23:08

#include<cstdio>

#include<functional>

#include<algorithm>

#include<cstring>

using namespace std;

int main()

{

char n[100001];

bool no = 0;

scanf("%s", &n);

int len = strlen(n), sum = 0;

sort(&n[0], &n[len],greater<char>());

if (n[len - 1] == '0')

{

for (int i = 0; i < len; ++i)

sum += n[i] - '0';

if (sum % 3 != 0)

no = 1;

}

else

no = 1;

(no == 1) ? printf("-1") : printf("%s", n);

}