From 1da6b0c8cd81a4e4035a498dc16e18f23d7186ec Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Sat, 13 Dec 2025 17:31:00 +0900 Subject: [PATCH] =?UTF-8?q?[20251213]=20PGM=20/=20Lv2=20/=20=EB=8B=A4?= =?UTF-8?q?=EC=9D=8C=20=ED=81=B0=20=EC=88=AB=EC=9E=90=20/=20=EC=9D=B4?= =?UTF-8?q?=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \355\201\260 \354\210\253\354\236\220.md" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "0224LJH/202512/13 PGM \353\213\244\354\235\214\343\205\201 \355\201\260 \354\210\253\354\236\220.md" diff --git "a/0224LJH/202512/13 PGM \353\213\244\354\235\214\343\205\201 \355\201\260 \354\210\253\354\236\220.md" "b/0224LJH/202512/13 PGM \353\213\244\354\235\214\343\205\201 \355\201\260 \354\210\253\354\236\220.md" new file mode 100644 index 00000000..17acfe72 --- /dev/null +++ "b/0224LJH/202512/13 PGM \353\213\244\354\235\214\343\205\201 \355\201\260 \354\210\253\354\236\220.md" @@ -0,0 +1,33 @@ +```java +import java.io.*; +import java.util.*; + +class Solution { + public int solution(int n) { + + int goalCnt = getTwoCnt(n); + + int num = n+1; + + while (true){ + int target = num; + int tempTwoCnt = getTwoCnt(target); + if (tempTwoCnt == goalCnt) { + break; + } + num++; + } + return num; + } + + public int getTwoCnt(int n){ + int result = 0; + while (n > 0){ + if (n%2 != 0) result++; + n /=2; + } + + return result; + } +} +```