No older revisions available
No older revisions available
문제 보기
----
걸린 시간 : 30분
(zeropage)코드레이스출동 연습
----
프로그래밍
----
걸린 시간 : 30분
~java import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Pinary { private static String processOneCase(String line) { int limit = Integer.parseInt(line); int count = 0; String number; boolean accept = true; for(int i = 0; i < 90000000 * 2; i++) { accept = true; number = Integer.toBinaryString(i); if (number.charAt(0) == '0') { continue; } int size = number.length(); for(int j = 0; j < size - 1; j++) { if (number.substring(j, j+2).matches("11")) { accept = false; break; } } if (accept) { count++; } if (count == limit) { return number; } } return null; } public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new FileReader("test.txt")); String line = br.readLine(); int testCase = Integer.parseInt(line); for(int i = 0; i < testCase; i++) { line = br.readLine(); String result = processOneCase(line); System.out.println(result); } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }----
(zeropage)코드레이스출동 연습
----
프로그래밍