baekjoon 20251215-17
This commit is contained in:
parent
80a44165ae
commit
346dc68487
33
code_study/Baekjoon/java/_9527.java
Normal file
33
code_study/Baekjoon/java/_9527.java
Normal file
@ -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));
|
||||
}
|
||||
}
|
||||
36
code_study/Baekjoon/python/20040.py
Normal file
36
code_study/Baekjoon/python/20040.py
Normal file
@ -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)
|
||||
3
code_study/Baekjoon/python/5337.py
Normal file
3
code_study/Baekjoon/python/5337.py
Normal file
@ -0,0 +1,3 @@
|
||||
print(". . .")
|
||||
print("| | _ | _. _ ._ _ _")
|
||||
print("|/\|(/.|(_.(_)[ | )(/.")
|
||||
1
code_study/Baekjoon/python/9654.py
Normal file
1
code_study/Baekjoon/python/9654.py
Normal file
@ -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 ")
|
||||
Loading…
x
Reference in New Issue
Block a user