-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathI064.java
31 lines (29 loc) · 949 Bytes
/
I064.java
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
package levelB;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.TreeSet;
public class I064 {
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int N=Integer.parseInt(br.readLine());
String[] str=br.readLine().split(" ");
TreeSet<Integer> set=new TreeSet<>();
for(int i=0;i<N;i++){
int sum=0;
char[] c=str[i].toCharArray();
for(int j=0;j<c.length;j++)
sum+=c[j]-48;
set.add(sum);
}
System.out.println(set.size());
Iterator<Integer> it=set.iterator();
int count=0;
while(it.hasNext()){
if(count!=0)
System.out.print(" ");
System.out.print(it.next());
count++;
}
}
}