본문 바로가기

파이썬2187

[백준/파이썬] 32888번 Consolidating Windows -Codefrom math import sqrta, b = map(int, input().split())print(sqrt(a ** 2 + b ** 2)) 2024. 12. 17.
[백준/파이썬] 10187번 Golden -Codefrom math import sqrtgolden_ratio = (1 + sqrt(5)) / 2for _ in range(int(input())): a, b = map(float, input().split()) if a 2024. 12. 16.
[백준/파이썬] 32560번 Amalgram -Codefrom collections import Counter # 갯수를 쉽게 세어 딕셔너리 작성a = input()b = input()count = Counter(a) | Counter(b) # 최대 합집합res = ""for key, val in count.items(): res += key * valprint(res)Counter와 합집합을 찾게되어 그것으로 해결했습니다 2024. 12. 15.
[백준/파이썬] 9297번 Reducing Improper Fractions -Codefor i in range(1, int(input()) + 1): n, d = map(int, input().split()) if n % d == 0: print(f"Case {i}: {n // d}") elif n // d == 0: print(f"Case {i}: {n % d}/{d}") else: print(f"Case {i}: {n // d} {n % d}/{d}") 2024. 12. 14.
[백준/파이썬] 6812번 Good times -Codeottawa = int(input())print(f"{ottawa} in Ottawa")victoria = ottawa - 300 if ottawa - 300 >= 0 else ottawa + 2100print(f"{victoria} in Victoria")edmonton = ottawa - 200 if ottawa - 200 >= 0 else ottawa + 2200print(f"{edmonton} in Edmonton")winnipeg = ottawa - 100 if ottawa - 100 >= 0 else ottawa + 2300print(f"{winnipeg} in Winnipeg")print(f"{ottawa} in Toronto")halifax = (ottawa + 100) % 240.. 2024. 12. 13.
[백준/파이썬] 32682번 Which Number Kind Is It? -Codefrom math import sqrtfrom sys import stdininput = stdin.readlinefor _ in range(int(input())): n = int(input()) res = "" if n % 2 == 1: res += "O" if int(sqrt(n)) ** 2 == n: res += "S" if res == "": res = "EMPTY" print(res) 2024. 12. 12.