From 08c1b1d91c748095ca28b337dc94eb18c87f79b3 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Sat, 6 Sep 2025 17:23:35 +0900 Subject: [PATCH] =?UTF-8?q?[20250906]=20BOJ=20/=20G4=20/=202=EB=A1=9C=20?= =?UTF-8?q?=EB=AA=87=EB=B2=88=20=EB=82=98=EB=88=84=EC=96=B4=EC=A7=88?= =?UTF-8?q?=EA=B9=8C=20/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...04\354\226\264\354\247\210\352\271\214.md" | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "0224LJH/202509/06 BOJ 2\353\241\234 \353\252\207\353\262\210 \353\202\230\353\210\204\354\226\264\354\247\210\352\271\214.md" diff --git "a/0224LJH/202509/06 BOJ 2\353\241\234 \353\252\207\353\262\210 \353\202\230\353\210\204\354\226\264\354\247\210\352\271\214.md" "b/0224LJH/202509/06 BOJ 2\353\241\234 \353\252\207\353\262\210 \353\202\230\353\210\204\354\226\264\354\247\210\352\271\214.md" new file mode 100644 index 00000000..cff772c2 --- /dev/null +++ "b/0224LJH/202509/06 BOJ 2\353\241\234 \353\252\207\353\262\210 \353\202\230\353\210\204\354\226\264\354\247\210\352\271\214.md" @@ -0,0 +1,59 @@ +```java +import java.io.IOException; +import java.io.*; +import java.util.*; + + +public class Main { + static long from,to,sum; + static long[] cnts = new long[61]; + + + public static void main(String[] args) throws IOException { + init(); + process(); + print(); + } + + public static void init() throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + from = Long.parseLong(st.nextToken()); + to = Long.parseLong(st.nextToken()); + + + } + + public static void process() throws IOException { + for (int i = 0; i < 61; i++) { + long num = 1L << i; + + long cnt = to/num - from/num; + if (from%num == 0) cnt++; + + cnts[i] = cnt; + } + + sum = 0; + long pre = 0; + for (int i = 60; i >= 0; i--) { + long num = 1L << i; + + sum += (cnts[i]-pre) * num; + pre = cnts[i]; + } + + } + + + + + + + + public static void print() { + System.out.println(sum); + } +} + +```