Under my umbrella.

SKII

Less is more.

洛谷 P1059 明明的随机数 (JAVA)

洛谷 P1059 明明的随机数

import java.util.Scanner;
import java.util.TreeSet;
import java.util.Iterator;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        TreeSet<Integer> ts = new TreeSet<>();
        for(int i = 0; i < n; i++) {
            ts.add(scan.nextInt());
        }
        System.out.println(ts.size());
        Iterator<Integer> it = ts.iterator();
        while(it.hasNext()) {
            System.out.print(it.next());
            if(it.hasNext()) System.out.print(" ");
        }
    }
}
posted @ 2020-01-21 16:33  NLYang  阅读(529)  评论(0编辑  收藏  举报