테스트 데이터를 가지고 돌렸을 경우 테스트가 정상적으로 완료가 되는데 실제로는 오답이 되네요..
importjava.util.ArrayList;importjava.util.Collections;importjava.util.List;importjava.util.Scanner;/* * not solve the this problem at july thirty-One */publicclassMain{publicstaticabstractclassBitNum{publicabstractStringgetBitnum();};publicstaticclassBlefuscuextendsBitNumimplementsComparable<Blefuscu>{privateStringbitnum;privateintbitCount;Blefuscu(StringbitString){this.bitnum=bitString;}@OverridepublicStringtoString(){return"BitNum [bitnum="+bitnum+", bitCount="+bitCount+"]";}@OverridepublicintcompareTo(Blefuscuo){// TODO Auto-generated method stubreturnInteger.valueOf(o.bitnum,2)-Integer.valueOf(this.bitnum,2);}@OverridepublicStringgetBitnum(){// TODO Auto-generated method stubreturnthis.bitnum;}}publicstaticclassLilliputextendsBitNumimplementsComparable<Lilliput>{privateStringbitnum;privateintbitCount;Lilliput(StringbitString){this.bitnum=bitString;}@OverridepublicStringtoString(){return"Lilliput [bitnum="+bitnum+", bitCount="+bitCount+"]";}@OverridepublicintcompareTo(Lilliputo){// TODO Auto-generated method stubreturnInteger.valueOf(this.bitnum,2)-Integer.valueOf(o.bitnum,2);}@OverridepublicStringgetBitnum(){// TODO Auto-generated method stubreturnthis.bitnum;}}publicstaticvoidmain(String[]args){Scannersc=newScanner(System.in);intcases=Integer.valueOf(sc.nextLine());while(cases-->0){longnum=Long.valueOf(sc.nextLine());StringbitString=Long.toBinaryString(num);inti=0;bitString=matchlength(bitString);List<Blefuscu>Blelist=newArrayList<Blefuscu>();List<Lilliput>Lillist=newArrayList<Lilliput>();while(i<4){Blelist.add(newBlefuscu(bitString.substring(i*8,(i+1)*8)));Lillist.add(newLilliput(bitString.substring(i*8,(i+1)*8)));i++;}Collections.sort(Blelist);Collections.sort(Lillist);longbr=getNum(Blelist);longlr=getNum(Lillist);if(br==num){System.out.println(lr);}else{System.out.println(br);}}}publicstatic<TextendsBitNum>longgetNum(List<T>list){StringBuffersb=newStringBuffer();for(Tbn:list){sb.append(bn.getBitnum());}returnLong.valueOf(sb.toString(),2);}publicstaticStringmatchlength(StringbitNumString){while(bitNumString.length()!=32){bitNumString="0"+bitNumString;}returnbitNumString;}}
bongster
테스트 데이터를 가지고 돌렸을 경우 테스트가 정상적으로 완료가 되는데 실제로는 오답이 되네요..
10년 전