PKU 1552 "Doubles"
問題:http://acm.pku.edu.cn/JudgeOnline/problem?id=1552
順位:http://acm.pku.edu.cn/JudgeOnline/problemstatus?problem_id=1552&orderby=clen&language=2
提出コード(215B)
import java.util.*;class Main{static{Scanner s=new Scanner(System.in);for(int n,c;(n=s.nextInt())>0;){Set l=new HashSet();c=0;do{l.add(n);l.add(n*2);++c;}while((n=s.nextInt())>0);System.out.println(2*c-l.size());}}}
整形コード
class Main { static { Scanner s = new Scanner(System.in); for (int n, c; (n = s.nextInt()) > 0;) { Set l = new HashSet(); c = 0; do { l.add(n); l.add(n * 2); ++c; } while ((n = s.nextInt()) > 0); System.out.println(2 * c - l.size()); } } }