VioletaBabel
10610번: 30 본문
#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);
}
'백준 > 백준-C++' 카테고리의 다른 글
1654번: 랜선 자르기 (0) | 2017.06.14 |
---|---|
11728번: 배열 합치기 (0) | 2017.06.14 |
2875번: 대회 or 인턴 (0) | 2017.06.13 |
1744번: 수 묶기 (0) | 2017.06.13 |
1541번: 잃어버린 괄호 (0) | 2017.06.13 |
Comments