티스토리 뷰
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 30 | public class Level1_3진법뒤집기 { public static int solution(int n) { int answer = 0; // 10진법 -> 3진법 뒤집은거 StringBuilder reverseThreeRadix = new StringBuilder(); while (n > 0) { reverseThreeRadix.append(n % 3); n /= 3; } // 3진법 -> 10진법 long before10 = Long.parseLong(reverseThreeRadix.toString()); int count = 0; while (before10 > 0) { long index = before10 % 10; answer += index * (int) Math.pow(3, count++); before10 /= 10; } return answer; } public static void main(String[] args) { int n = 45; System.out.println(solution(n)); } } | cs |
'PS > programmers' 카테고리의 다른 글
Level1) 소수구하기 (0) | 2021.04.30 |
---|---|
Level1) 신규아이디추천 (0) | 2021.04.29 |
Level1) 키패드 누르기 (0) | 2021.04.27 |
Level1) 다트게임 (0) | 2021.04.27 |
Level1) 비밀지도 (0) | 2021.03.17 |
링크
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- js api
- GCP
- JPA 연관관계 매핑
- 백기선 스터디
- js promise
- 김영한 JPA
- 드림코딩
- 김영한 http
- Spring Security
- HTTP 완벽 가이드
- dreamcoding
- http
- 모던자바스크립트
- HTTP 완벽가이드
- BOJ
- 패스트캠퍼스 컴퓨터공학 완주반
- 프로그래머스
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- 이펙티브자바 아이템59
- 이펙티브자바 아이템60
- REST API
- js array
- ㅇㄷㅇㅈ
- 백준
- 킹수빈닷컴
- 프로그래머스 SQL
- 이펙티브자바
- java
- JS 딥다이브
- 이펙티브자바 스터디
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 30 |
글 보관함