본문 바로가기 메뉴 바로가기

지제로의 블로그

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

지제로의 블로그

검색하기 폼
  • 분류 전체보기 (44)
    • algorithm (17)
    • CS (7)
      • OS (6)
    • server (3)
      • Node.js (1)
      • Spring (9)
      • database (1)
      • devops (1)
    • data (4)
      • ML (1)
      • DL (0)
    • android (1)
    • 회고 (0)
  • 방명록

다음큰숫자 (1)
[프로그래머스] 다음 큰 숫자 (C++)

풀이과정 1. 입력된 n의 1의 개수를 구한다. 2. n의 값을 하나씩 크게 해서 1의 개수가 같을 때 해당 n을 반환한다. #include #include using namespace std; int toBinary(int n){ int count=0; while(n>0){ if(n%2==1) count++; n/=2; } return count; } int toBigger(int n, int count){ while(1){ int tmp_one=toBinary(++n); if(tmp_one==count) break; } return n; } int solution(int n) { int answer = 0; int one_count=toBinary(n); //현재 n의 1의 개수 return toBi..

algorithm 2022. 9. 26. 16:36
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
  • Github
TAG
  • 응답코드
  • OS
  • qemu
  • 영어끝말잇기
  • 프로그래머스
  • 정수삼각형
  • 괄호회전하기
  • 최고의집합
  • 머신러닝
  • interrupt
  • 운영체제
  • RDS
  • 뉴스클러스터링
  • dp
  • 다음큰숫자
  • PasswordEncoder
  • Auditing
  • 백준
  • 최솟값구하기
  • AWS
  • 우분투설치
  • springboot
  • PostgreSQL
  • 시스템콜
  • xv6
  • Android
  • 실패율
  • 이진변환반복하기
  • 프리티어
  • ubuntu
more
«   2025/06   »
일 월 화 수 목 금 토
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
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바