최's 먹공로그
SEA3459_승자예측하기 본문
xxxxxxxxxximport java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;public class Solution { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int test_case = Integer.parseInt(br.readLine().trim()); long[] arr = new long[10000]; arr[0] = 1; int cnt = 1; /** * 1,4,4,16,16,64,64,256,256......이런배열에서 전값을 계속 더해서 배열에 저장 * 1,5,9,25,41......이런식으로 이게 최종 arr */ for (int i = 1; i < 10000; i++) { arr[i] += arr[i-1] + Math.pow(4, cnt); if(i % 2 == 0) { cnt++; } } for (int tc = 1; tc <= test_case; tc++) { long n = Long.parseLong(br.readLine().trim()); for (int i = 0; i < 10000; i++) { if(arr[i] >= n) { // arr에 있는 현재값이 n보다 크거나 같아지는 순간 // i가 짝수일때가 Bob의 범위 if(i % 2 == 0) System.out.println("#" + tc + " " + "Bob"); // i가 홀수일대는 Alice의 범위 else System.out.println("#" + tc + " " + "Alice"); break; } } } // end of tc } // end of main} // end of class
'APS' 카테고리의 다른 글
| SEA3752_가능한 시험점수 (0) | 2019.03.07 |
|---|---|
| SEA1493_수의 새로운 연산 (0) | 2019.03.07 |
| 백준3055_탈출 (0) | 2019.03.06 |
| SEA1257_[S/W 문제해결 응용] 6일차_K번째 문자열 (0) | 2019.02.26 |
| 백준1012_유기농배추 (0) | 2019.02.26 |