-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathB1064.cpp
More file actions
51 lines (47 loc) · 1.05 KB
/
B1064.cpp
File metadata and controls
51 lines (47 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*************************************************************************
> File Name: B1064.cpp
> Author: bumzy
> Mail: bumzy@gmail.com
> Created Time: 2017年07月30日 星期日 16时10分03秒
************************************************************************/
#include <stdio.h>
using namespace std;
int const MAX = 64;
int sum_of_digit(int num) {
int sum = 0;
while (num) {
sum += num % 10;
num /= 10;
}
return sum;
}
int count[MAX] = {0};
int main(void) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int num;
scanf("%d", &num);
count[sum_of_digit(num)]++;
}
int m = 0;
for (int i = 0; i < MAX; ++i) {
if (count[i]) {
m++;
}
}
printf("%d\n", m);
bool first = true;
for (int i = 0; i < MAX; ++i) {
if (count[i]) {
if (first) {
first = false;
} else {
printf(" ");
}
printf("%d", i);
}
}
printf("\n");
return 0;
}