From 346dc68487bf655628c1a571cf1a5b8f8f737b4a Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Wed, 17 Dec 2025 17:31:32 +0900 Subject: [PATCH] baekjoon 20251215-17 --- code_study/Baekjoon/java/_9527.java | 33 ++++++++++++++++++++++++++ code_study/Baekjoon/python/20040.py | 36 +++++++++++++++++++++++++++++ code_study/Baekjoon/python/5337.py | 3 +++ code_study/Baekjoon/python/9654.py | 1 + 4 files changed, 73 insertions(+) create mode 100644 code_study/Baekjoon/java/_9527.java create mode 100644 code_study/Baekjoon/python/20040.py create mode 100644 code_study/Baekjoon/python/5337.py create mode 100644 code_study/Baekjoon/python/9654.py diff --git a/code_study/Baekjoon/java/_9527.java b/code_study/Baekjoon/java/_9527.java new file mode 100644 index 0000000..ce7f00c --- /dev/null +++ b/code_study/Baekjoon/java/_9527.java @@ -0,0 +1,33 @@ +import java.util.*; + +public class _9527 { + static long[] power2 = new long[55]; + + static long getCountOne(long N) { + long ans = 0; + + for(int i = 54; i>0; i--) { + long mark = (N & (1L << (i-1))); + + if(mark != 0) { + ans += power2[i-1] + (N - mark + 1); + N -= mark; + } + } + + return ans; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + long A = sc.nextLong(); + long B = sc.nextLong(); + sc.close(); + + for(int i=1; i<55; i++) { + power2[i] = 2*power2[i-1] + (1L << (i-1)); + } + + System.out.println(getCountOne(B) - getCountOne(A-1)); + } +} \ No newline at end of file diff --git a/code_study/Baekjoon/python/20040.py b/code_study/Baekjoon/python/20040.py new file mode 100644 index 0000000..f24204a --- /dev/null +++ b/code_study/Baekjoon/python/20040.py @@ -0,0 +1,36 @@ +import sys +input = sys.stdin.readline + +n, m = map(int, input().split()) +parents = [i for i in range(n)] +rank = [0]*n + +def find(x): + if parents[x] != x: + parents[x] = find(parents[x]) + return parents[x] + +def union(x, y) : + x = find(x) + y = find(y) + + if x == y : return False + + if rank[x] > rank[y] : + parents[y] = x + else : + parents[x] = y + if rank[x] == rank[y] : + rank[y] += 1 + + return True + +ans = 0 +for i in range(m) : + a, b = map(int, input().split()) + + if not union(a,b) : + ans = i+1 + break + +print(ans) \ No newline at end of file diff --git a/code_study/Baekjoon/python/5337.py b/code_study/Baekjoon/python/5337.py new file mode 100644 index 0000000..d0a35d9 --- /dev/null +++ b/code_study/Baekjoon/python/5337.py @@ -0,0 +1,3 @@ +print(". . .") +print("| | _ | _. _ ._ _ _") +print("|/\|(/.|(_.(_)[ | )(/.") \ No newline at end of file diff --git a/code_study/Baekjoon/python/9654.py b/code_study/Baekjoon/python/9654.py new file mode 100644 index 0000000..2870fcc --- /dev/null +++ b/code_study/Baekjoon/python/9654.py @@ -0,0 +1 @@ +print("SHIP NAME CLASS DEPLOYMENT IN SERVICE\nN2 Bomber Heavy Fighter Limited 21 \nJ-Type 327 Light Combat Unlimited 1 \nNX Cruiser Medium Fighter Limited 18 \nN1 Starfighter Medium Fighter Unlimited 25 \nRoyal Cruiser Light Combat Limited 4 ") \ No newline at end of file