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); + } +} + +```