Blue___
코딩배우는 학생🌎
Blue___
전체 방문자
오늘
어제
  • 코딩배우는 학생🧀 (242)
    • Algorithms (145)
      • BOJ[Java] (107)
      • Programmers[Java] (32)
      • Coding_Contest (3)
    • Web (22)
      • .NET Core C# (2)
      • Java (1)
      • Oracle SQL (7)
      • Web-ProJect (3)
      • Error처리 (1)
      • Web지식 (4)
      • Javascript (1)
      • Vue (3)
    • Git (4)
    • Java_beginner(Repl.it) (55)
      • Auto-Graded-Course(AP CS A) (54)
    • 프로젝트 직딩일기 (3)
    • Hanyang_Assignment (0)
    • 이모저모 (4)
      • 잡담 (1)
      • 2021 오픈소스 컨트리뷰터 아카데미 (1)
      • DDD - 6기! (1)
    • 북리뷰 (1)
      • 리팩토링 2판 (1)
      • 클린코드 (0)

블로그 메뉴

  • 🐰GITHUB
  • ☘️포트폴리오
  • 🌸MBC개발_투표 2022
  • 🍭MBC_APP

공지사항

인기 글

태그

  • Java
  • 코딩배우는 학생
  • 레플릿
  • 알고리즘
  • programmers
  • REPL
  • repl.it
  • 백준
  • Bakjoon
  • 프로그래밍
  • 코딩배우는학생
  • java basic
  • 코딩
  • auto-graded course
  • Java tutorial
  • 프로그래머스
  • AP CS A
  • coding
  • algorithm
  • 자바

최근 댓글

최근 글

티스토리

hELLO
Blue___

코딩배우는 학생🌎

[백준/11104번] Fridge of Your Dreams ( IDI Open 2007 )[Java]
Algorithms/BOJ[Java]

[백준/11104번] Fridge of Your Dreams ( IDI Open 2007 )[Java]

2019. 12. 9. 15:18

Ploblem

Eirik drinks a lot of Bingo Cola to help him program faster, and over the years he has burned many unnecessary calories walking all the way to the kitchen to get some. To avoid this he has just bought a small fridge, which is beautifully placed next to his computer. To make it match his fancy big-tower with all its blinking LEDs, it is necessary to style it a bit.

He has bought a weight sensor with a display and a small general purpose programmable chip, to put underneath the fridge. The idea is to make the display show how many litres of Bingo Cola there is in the fridge. To do this he must read a binary register in the sensor, and convert it to a decimal number to be displayed.

Input

The first line of input gives n ≤ 1000, the number of test cases. Then follow n lines with positive numbers represented as 24-bit binary strings (0s and 1s).

Output

For each number, output its decimal representation, without any leading zeros.

 


Solution

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.*;
import java.io.*;
 
 
 
class Bakjoon {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in); 
       int n=sc.nextInt();
       Long result=(long) 0;       
       Long cnt =(long) 1;
       
       for(int i=0;i<n;i++) {
               String [] arr =sc.next().split("");
                           
               for(int j=23;j>=0;j--) {
                   result+= Integer.parseInt(arr[j])*cnt;
                           cnt*=2;
               }
               System.out.println(result);
               cnt=(long)1;
               result=(long)0;
       }
    }
}
 
    
 
    
 
 

https://www.acmicpc.net/problem/11104

 

11104번: Fridge of Your Dreams

Eirik drinks a lot of Bingo Cola to help him program faster, and over the years he has burned many unnecessary calories walking all the way to the kitchen to get some. To avoid this he has just bought a small fridge, which is beautifully placed next to his

www.acmicpc.net

 

반응형
저작자표시 (새창열림)

'Algorithms > BOJ[Java]' 카테고리의 다른 글

[백준/13597번] Tri-du( A Primeira Fase da Maratona de Programação 2015) [Java]  (0) 2019.12.09
[백준/11319번] Count Me In (CCPC 2015 Division 2) [Java]  (0) 2019.12.09
[백준/5988번] 홀수일까 짝수일까 [Java]  (0) 2019.12.09
[백준/10669번] 오늘 날짜 [Java]  (0) 2019.12.09
[백준/10093번] 숫자 [Java]  (0) 2019.12.09
    'Algorithms/BOJ[Java]' 카테고리의 다른 글
    • [백준/13597번] Tri-du( A Primeira Fase da Maratona de Programação 2015) [Java]
    • [백준/11319번] Count Me In (CCPC 2015 Division 2) [Java]
    • [백준/5988번] 홀수일까 짝수일까 [Java]
    • [백준/10669번] 오늘 날짜 [Java]
    Blue___
    Blue___
    완전 연소한 불은 재를 남기지않는다 : 코딩배우는학생 🌎

    티스토리툴바