diff --git "a/Baekjoon Online Judge/11_\346\234\210_November.py" "b/Baekjoon Online Judge/11_\346\234\210_November.py" new file mode 100644 index 0000000..9476980 --- /dev/null +++ "b/Baekjoon Online Judge/11_\346\234\210_November.py" @@ -0,0 +1,7 @@ +a = int(input()) +b = int(input()) + +if a + (7 * b) <= 30: + print(1) +else: + print(0) diff --git "a/Baekjoon Online Judge/2023_\354\235\200_\353\254\264\354\227\207\354\235\264_\355\212\271\353\263\204\355\225\240\352\271\214.py" "b/Baekjoon Online Judge/2023_\354\235\200_\353\254\264\354\227\207\354\235\264_\355\212\271\353\263\204\355\225\240\352\271\214.py" new file mode 100644 index 0000000..b3410ef --- /dev/null +++ "b/Baekjoon Online Judge/2023_\354\235\200_\353\254\264\354\227\207\354\235\264_\355\212\271\353\263\204\355\225\240\352\271\214.py" @@ -0,0 +1,9 @@ +count = int(input()) + +for _ in range(count): + number = int(input()) + target = number + 1 + if target % int(str(number)[-2:]) == 0: + print("Good") + else: + print("Bye") diff --git "a/Baekjoon Online Judge/2033_\353\205\204_\353\260\210_\355\210\254\355\221\234.py" "b/Baekjoon Online Judge/2033_\353\205\204_\353\260\210_\355\210\254\355\221\234.py" new file mode 100644 index 0000000..2dc71f0 --- /dev/null +++ "b/Baekjoon Online Judge/2033_\353\205\204_\353\260\210_\355\210\254\355\221\234.py" @@ -0,0 +1,15 @@ +PROMISES = [ + "Never gonna give you up", + "Never gonna let you down", + "Never gonna run around and desert you", + "Never gonna make you cry", + "Never gonna say goodbye", + "Never gonna tell a lie and hurt you", + "Never gonna stop", +] + +loop = int(input()) +if all(input() in PROMISES for _ in range(loop)): + print("No") +else: + print("Yes") diff --git a/Baekjoon Online Judge/27323.py b/Baekjoon Online Judge/27323.py new file mode 100644 index 0000000..39b22f4 --- /dev/null +++ b/Baekjoon Online Judge/27323.py @@ -0,0 +1,9 @@ +import math + + +def solution(number: int) -> int: + return math.factorial(number) + + +if __name__ == "__main__": + print(solution(number=int(input()))) diff --git a/Baekjoon Online Judge/27866.py b/Baekjoon Online Judge/27866.py new file mode 100644 index 0000000..8c43991 --- /dev/null +++ b/Baekjoon Online Judge/27866.py @@ -0,0 +1,8 @@ +def solution(target_string: str, index_: int) -> str: + return target_string[index_ - 1] + + +if __name__ == "__main__": + target_string = input() + index_ = int(input()) + print(solution(target_string, index_)) diff --git "a/Baekjoon Online Judge/2_\346\241\201\343\201\256\346\225\264\346\225\260_Two_digit_Integer.py" "b/Baekjoon Online Judge/2_\346\241\201\343\201\256\346\225\264\346\225\260_Two_digit_Integer.py" new file mode 100644 index 0000000..ee87dcf --- /dev/null +++ "b/Baekjoon Online Judge/2_\346\241\201\343\201\256\346\225\264\346\225\260_Two_digit_Integer.py" @@ -0,0 +1,4 @@ +a = int(input()) +b = int(input()) + +print(a * 10 + b) diff --git "a/Baekjoon Online Judge/AI_\354\204\240\353\217\204\353\214\200\355\225\231.py" "b/Baekjoon Online Judge/AI_\354\204\240\353\217\204\353\214\200\355\225\231.py" new file mode 100644 index 0000000..66e76bb --- /dev/null +++ "b/Baekjoon Online Judge/AI_\354\204\240\353\217\204\353\214\200\355\225\231.py" @@ -0,0 +1,2 @@ +target_year = int(input()) +print(target_year - 2024) \ No newline at end of file diff --git a/Baekjoon Online Judge/A_B.cpp b/Baekjoon Online Judge/A_B.cpp new file mode 100644 index 0000000..4c009e0 --- /dev/null +++ b/Baekjoon Online Judge/A_B.cpp @@ -0,0 +1,12 @@ +#include + +int sum(int A, int B) { + return A + B; +} + +int main() { + int A, B; + std::cin >> A >> B; + std::cout << sum(A, B) << std::endl; + return 0; +} diff --git a/Baekjoon Online Judge/A_B.py b/Baekjoon Online Judge/A_B.py new file mode 100644 index 0000000..935466b --- /dev/null +++ b/Baekjoon Online Judge/A_B.py @@ -0,0 +1,7 @@ +def solution(a: int, b: int) -> int: + return a + b + + +a = int(input()) +b = int(input()) +print(solution(a, b)) diff --git a/Baekjoon Online Judge/A_B_C_A_B_C.py b/Baekjoon Online Judge/A_B_C_A_B_C.py new file mode 100644 index 0000000..abe2875 --- /dev/null +++ b/Baekjoon Online Judge/A_B_C_A_B_C.py @@ -0,0 +1,11 @@ +def main(a, b, c): + print(a + b - c ) + print(int(str(a) + str(b)) - c) + + +if __name__ == "__main__": + a = int(input()) + b = int(input()) + c = int(input()) + + main(a, b, c) diff --git a/Baekjoon Online Judge/Adding_Trouble.py b/Baekjoon Online Judge/Adding_Trouble.py new file mode 100644 index 0000000..c568eca --- /dev/null +++ b/Baekjoon Online Judge/Adding_Trouble.py @@ -0,0 +1,5 @@ +a, b, c = map(int, input().split()) +if a + b == c: + print("correct!") +else: + print("wrong!") diff --git a/Baekjoon Online Judge/Affischutskicket.py b/Baekjoon Online Judge/Affischutskicket.py new file mode 100644 index 0000000..62bac67 --- /dev/null +++ b/Baekjoon Online Judge/Affischutskicket.py @@ -0,0 +1,5 @@ +c4_g, a3_g, a4_g = map(int, input().split()) +c4 = c4_g * 0.229 * 0.324 +a3 = a3_g * 0.297 * 0.42 +a4 = a4_g * 0.21 * 0.297 +print(f"{2*c4 + 2*a3 + a4:.6f}") \ No newline at end of file diff --git a/Baekjoon Online Judge/An_Easy_Peasy_Problem.py b/Baekjoon Online Judge/An_Easy_Peasy_Problem.py new file mode 100644 index 0000000..c5678c5 --- /dev/null +++ b/Baekjoon Online Judge/An_Easy_Peasy_Problem.py @@ -0,0 +1,6 @@ +solved_people, total_people = map(int, input().split()) + +if (solved_people / total_people) >= 0.5: + print("E") +else: + print("H") diff --git a/Baekjoon Online Judge/Andando_no_tempo.py b/Baekjoon Online Judge/Andando_no_tempo.py new file mode 100644 index 0000000..8cd811e --- /dev/null +++ b/Baekjoon Online Judge/Andando_no_tempo.py @@ -0,0 +1,12 @@ +from itertools import combinations + + +a, b, c = map(int, input().split()) + + +if a == b or a == c or b == c: + print("S") +elif a + b == c or a + c == b or b + c == a: + print("S") +else: + print("N") diff --git a/Baekjoon Online Judge/Another_Eruption.py b/Baekjoon Online Judge/Another_Eruption.py new file mode 100644 index 0000000..5f42f1a --- /dev/null +++ b/Baekjoon Online Judge/Another_Eruption.py @@ -0,0 +1,6 @@ +from math import pi + +a = int(input()) +r = (a / pi) ** 0.5 + +print(f"{2 * pi * r:.9f}") diff --git a/Baekjoon Online Judge/Arno_s_Sleep_Schedule.py b/Baekjoon Online Judge/Arno_s_Sleep_Schedule.py new file mode 100644 index 0000000..1aa156e --- /dev/null +++ b/Baekjoon Online Judge/Arno_s_Sleep_Schedule.py @@ -0,0 +1,7 @@ +sleep_time = int(input()) +alarm_time = int(input()) + +if sleep_time in {0, 1, 2, 3}: + sleep_time += 24 + +print(abs(sleep_time - (alarm_time + 24))) diff --git a/Baekjoon Online Judge/Bank_Transfer.py b/Baekjoon Online Judge/Bank_Transfer.py new file mode 100644 index 0000000..1f74ae3 --- /dev/null +++ b/Baekjoon Online Judge/Bank_Transfer.py @@ -0,0 +1,2 @@ +k = int(input()) +print(f"{max(100, min(2000, 25 + 0.01 * k)):.2f}") diff --git a/Baekjoon Online Judge/Basketball_One_on_One.py b/Baekjoon Online Judge/Basketball_One_on_One.py new file mode 100644 index 0000000..6c29ca9 --- /dev/null +++ b/Baekjoon Online Judge/Basketball_One_on_One.py @@ -0,0 +1,20 @@ +input_ = input() + +result = [''.join(x) for x in zip(input_[::2], input_[1::2])] + +a = 0 +b = 0 + +for ele in result: + if ele[0] == "A": + a += int(ele[1]) + else: + b += int(ele[1]) + + if a >= 10 and b >= 10 and abs(a-b) >= 2: + break + +if a > b: + print("A") +else: + print("B") diff --git a/Baekjoon Online Judge/Betting.py b/Baekjoon Online Judge/Betting.py new file mode 100644 index 0000000..0fce49c --- /dev/null +++ b/Baekjoon Online Judge/Betting.py @@ -0,0 +1,4 @@ +a = int(input()) + +print(f"{((100 - a) / a) + 1:.10f}") +print(f"{((a / (100 - a)) + 1):.10f}") diff --git "a/Baekjoon Online Judge/Betygs\303\244ttning.py" "b/Baekjoon Online Judge/Betygs\303\244ttning.py" new file mode 100644 index 0000000..eb7e931 --- /dev/null +++ "b/Baekjoon Online Judge/Betygs\303\244ttning.py" @@ -0,0 +1,16 @@ +a, c, e = map(int, input().split()) +student_a, student_c, student_e = map(int, input().split()) + +if student_a == a and student_c == c and student_e == e: + print("A") +elif student_a >= a / 2 and student_c == c and student_e == e: + print("B") +elif student_c == c and student_e == e: + print("C") +elif student_c >= c / 2 and student_e == e: + print("D") +elif student_e == e: + print("E") +else: + raise ValueError("Invalid input") + \ No newline at end of file diff --git a/Baekjoon Online Judge/Bicycle.py b/Baekjoon Online Judge/Bicycle.py new file mode 100644 index 0000000..14363d5 --- /dev/null +++ b/Baekjoon Online Judge/Bicycle.py @@ -0,0 +1,17 @@ +a = int(input()) +x = int(input()) +b = int(input()) +y = int(input()) +t = int(input()) + +if t > 30: + option1 = a + (21 * (t - 30) * x) +else: + option1 = a + +if t > 45: + option2 = b + (21 * (t - 45) * y) +else: + option2 = b + +print(f"{option1} {option2}") diff --git a/Baekjoon Online Judge/Body_Mass_Index.py b/Baekjoon Online Judge/Body_Mass_Index.py new file mode 100644 index 0000000..fc5a53c --- /dev/null +++ b/Baekjoon Online Judge/Body_Mass_Index.py @@ -0,0 +1,11 @@ +weight = float(input()) +height = float(input()) + +bmi = weight / (height**2) + +if bmi < 18.5: + print("Underweight") +elif 18.5 <= bmi <= 25: + print("Normal weight") +else: + print("Overweight") diff --git a/Baekjoon Online Judge/Call_for_Problems.py b/Baekjoon Online Judge/Call_for_Problems.py new file mode 100644 index 0000000..ce582ba --- /dev/null +++ b/Baekjoon Online Judge/Call_for_Problems.py @@ -0,0 +1,5 @@ +from collections import Counter + +count = int(input()) +counter = Counter(num % 2 == 1 for num in [int(input()) for _ in range(count)]) +print(counter[True]) diff --git a/Baekjoon Online Judge/Checkers.py b/Baekjoon Online Judge/Checkers.py new file mode 100644 index 0000000..652c662 --- /dev/null +++ b/Baekjoon Online Judge/Checkers.py @@ -0,0 +1,7 @@ +a, b = map(int, input().split()) + +if a >= b: + print(b) +else: + if b != 0: + print(a + 1) diff --git a/Baekjoon Online Judge/Christmas_Tree_Adapter.py b/Baekjoon Online Judge/Christmas_Tree_Adapter.py new file mode 100644 index 0000000..435b264 --- /dev/null +++ b/Baekjoon Online Judge/Christmas_Tree_Adapter.py @@ -0,0 +1,7 @@ +a = int(input()) +w, v = map(int, input().split()) + +if w / v >= a: + print("1") +else: + print("0") diff --git a/Baekjoon Online Judge/Communication_Channels.py b/Baekjoon Online Judge/Communication_Channels.py new file mode 100644 index 0000000..45d59a7 --- /dev/null +++ b/Baekjoon Online Judge/Communication_Channels.py @@ -0,0 +1,8 @@ +t = int(input()) + +for _ in range(t): + n, m = map(str, input().split()) + if n == m: + print("OK") + else: + print("ERROR") diff --git a/Baekjoon Online Judge/Congruent_Numbers.py b/Baekjoon Online Judge/Congruent_Numbers.py new file mode 100644 index 0000000..7497dea --- /dev/null +++ b/Baekjoon Online Judge/Congruent_Numbers.py @@ -0,0 +1,6 @@ +p_1, q_1, p_2, q_2 = map(int, input().split()) +area = p_1 * p_2 / q_1 / q_2 / 2 +if int(area) == area: + print(1) +else: + print(0) \ No newline at end of file diff --git a/Baekjoon Online Judge/Conveyor_Belt_Sushi.py b/Baekjoon Online Judge/Conveyor_Belt_Sushi.py new file mode 100644 index 0000000..1e76402 --- /dev/null +++ b/Baekjoon Online Judge/Conveyor_Belt_Sushi.py @@ -0,0 +1,5 @@ +r = int(input()) +g = int(input()) +b = int(input()) + +print(r * 3 + g * 4 + b * 5) diff --git a/Baekjoon Online Judge/Counting_Antibodies.py b/Baekjoon Online Judge/Counting_Antibodies.py new file mode 100644 index 0000000..f6b8119 --- /dev/null +++ b/Baekjoon Online Judge/Counting_Antibodies.py @@ -0,0 +1,5 @@ +vk, jk = map(int, input().split()) +vl, jl = map(int, input().split()) +vh, dh, jh = map(int, input().split()) + +print(((vk * jk) + (vl * jl)) * (vh * dh * jh)) \ No newline at end of file diff --git a/Baekjoon Online Judge/Counting_Clauses.py b/Baekjoon Online Judge/Counting_Clauses.py new file mode 100644 index 0000000..426cad9 --- /dev/null +++ b/Baekjoon Online Judge/Counting_Clauses.py @@ -0,0 +1,11 @@ +m , n = map(int, input().split()) + +for _ in range(m): + list(map(int, input().split())) + +if m >= 8: + print("satisfactory") +else: + print("unsatisfactory") + + \ No newline at end of file diff --git a/Baekjoon Online Judge/Cutting_Corners.py b/Baekjoon Online Judge/Cutting_Corners.py new file mode 100644 index 0000000..d3e5a89 --- /dev/null +++ b/Baekjoon Online Judge/Cutting_Corners.py @@ -0,0 +1,5 @@ +w, h = map(int, input().split()) + +diagonal = (w ** 2 + h ** 2) ** (1/2) + +print(f"{w + h - diagonal:.9f}") diff --git "a/Baekjoon Online Judge/DKSH_\354\260\276\352\270\260.py" "b/Baekjoon Online Judge/DKSH_\354\260\276\352\270\260.py" new file mode 100644 index 0000000..aad4b56 --- /dev/null +++ "b/Baekjoon Online Judge/DKSH_\354\260\276\352\270\260.py" @@ -0,0 +1,2 @@ +target = input() +print(target.count("DKSH")) \ No newline at end of file diff --git a/Baekjoon Online Judge/Divide_the_Cash.py b/Baekjoon Online Judge/Divide_the_Cash.py new file mode 100644 index 0000000..a8f66ea --- /dev/null +++ b/Baekjoon Online Judge/Divide_the_Cash.py @@ -0,0 +1,7 @@ +n, d = map(int, input().split()) +result = [int(input()) for _ in range(n)] + +total = sum(result) + +for ele in result: + print(int(ele / total * d)) diff --git a/Baekjoon Online Judge/Easy_to_Solve_Expressions.py b/Baekjoon Online Judge/Easy_to_Solve_Expressions.py new file mode 100644 index 0000000..68d4c80 --- /dev/null +++ b/Baekjoon Online Judge/Easy_to_Solve_Expressions.py @@ -0,0 +1,20 @@ +from itertools import combinations + +inputs = list(map(int, input().split())) + +all_case_of_input = list(combinations(inputs, 2)) + + +all_case_of_add = list(map(lambda x: x[0] + x[1], all_case_of_input)) +all_case_of_mul = list(map(lambda x: x[0] * x[1], all_case_of_input)) + + +for input_ in inputs: + if input_ in all_case_of_add: + print(1) + break + if input_ in all_case_of_mul: + print(2) + break +else: + print(3) diff --git a/Baekjoon Online Judge/Everyone_is_a_winner.py b/Baekjoon Online Judge/Everyone_is_a_winner.py new file mode 100644 index 0000000..7c28da8 --- /dev/null +++ b/Baekjoon Online Judge/Everyone_is_a_winner.py @@ -0,0 +1,6 @@ +m, k = map(int, input().split()) + +if m % k == 0: + print("Yes") +else: + print("No") diff --git a/Baekjoon Online Judge/Final_Price.py b/Baekjoon Online Judge/Final_Price.py new file mode 100644 index 0000000..16bff48 --- /dev/null +++ b/Baekjoon Online Judge/Final_Price.py @@ -0,0 +1,5 @@ +n = int(input()) +initial_price = int(input()) +price_variations = [int(input()) for _ in range(n - 1)] + +print(initial_price + sum(price_variations)) diff --git a/Baekjoon Online Judge/Football_Team.py b/Baekjoon Online Judge/Football_Team.py new file mode 100644 index 0000000..6bf993e --- /dev/null +++ b/Baekjoon Online Judge/Football_Team.py @@ -0,0 +1,6 @@ +import sys + +translation = str.maketrans({"i": "e", "e": "i", "I": "E", "E": "I"}) + +for line in sys.stdin: + print(line.rstrip("\n").translate(translation)) diff --git a/Baekjoon Online Judge/Goodbye_Code_Jam.py b/Baekjoon Online Judge/Goodbye_Code_Jam.py new file mode 100644 index 0000000..fc5ad2f --- /dev/null +++ b/Baekjoon Online Judge/Goodbye_Code_Jam.py @@ -0,0 +1,13 @@ +loop = int(input()) + +for i in range(1, loop + 1): + rank = int(input()) + + if rank > 4500: + print(f"Case #{i}: Round 1") + elif rank > 1000: + print(f"Case #{i}: Round 2") + elif rank > 25: + print(f"Case #{i}: Round 3") + else: + print(f"Case #{i}: World Finals") diff --git a/Baekjoon Online Judge/Greetings.py b/Baekjoon Online Judge/Greetings.py new file mode 100644 index 0000000..16b9aa4 --- /dev/null +++ b/Baekjoon Online Judge/Greetings.py @@ -0,0 +1,5 @@ +n = input() + +e_count = n.count("e") + +print("h" + "e" * e_count * 2 + "y") diff --git a/Baekjoon Online Judge/HI_ARC.py b/Baekjoon Online Judge/HI_ARC.py new file mode 100644 index 0000000..695e224 --- /dev/null +++ b/Baekjoon Online Judge/HI_ARC.py @@ -0,0 +1,6 @@ +def solution(h: int, i: int, a: int, r: int, c: int) -> int: + return h * i - a * r * c + + +h, i, a, r, c = list(map(int, input().split())) +print(solution(h, i, a, r, c)) diff --git a/Baekjoon Online Judge/IT_Passport_Examination.py b/Baekjoon Online Judge/IT_Passport_Examination.py new file mode 100644 index 0000000..ea2e8cb --- /dev/null +++ b/Baekjoon Online Judge/IT_Passport_Examination.py @@ -0,0 +1,22 @@ +STRATEGY_PASS_SCORE = 35 +MANAGEMENT_PASS_SCORE = 25 +TECHNOLOGY_PASS_SCORE = 40 + + +n = int(input()) + +for _ in range(n): + identity_number, strategy_score, management_score, technology_score = map( + int, input().split() + ) + total_score = strategy_score + management_score + technology_score + + pass_condition = ( + total_score >= 55 + and strategy_score / STRATEGY_PASS_SCORE >= 0.3 + and management_score / MANAGEMENT_PASS_SCORE >= 0.3 + and technology_score / TECHNOLOGY_PASS_SCORE >= 0.3 + ) + result = "PASS" if pass_condition else "FAIL" + + print(f"{identity_number} {total_score} {result}") diff --git a/Baekjoon Online Judge/I_Speak_TXTMSG.py b/Baekjoon Online Judge/I_Speak_TXTMSG.py new file mode 100644 index 0000000..90101de --- /dev/null +++ b/Baekjoon Online Judge/I_Speak_TXTMSG.py @@ -0,0 +1,21 @@ +import sys + +maps = { + "CU": "see you", + ":-)": "I’m happy", + ":(": "I’m unhappy", + ";-)": "wink", + ":-P": "stick out my tongue", + "(~.~)": "sleepy", + "TA": "totally awesome", + "CCC": "Canadian Computing Competition", + "CUZ": "because", + "TY": "thank-you", + "YW": "you’re welcome", + "TTYL": "talk to you later", +} + + +for short_form in sys.stdin: + result = short_form.strip() + print(maps.get(result, result)) diff --git a/Baekjoon Online Judge/Java_Warriors.py b/Baekjoon Online Judge/Java_Warriors.py new file mode 100644 index 0000000..76593f6 --- /dev/null +++ b/Baekjoon Online Judge/Java_Warriors.py @@ -0,0 +1,5 @@ +REGISTRATION_FEE = 4000 + +team_count = int(input()) + +print(team_count * REGISTRATION_FEE) \ No newline at end of file diff --git a/Baekjoon Online Judge/Just_Round_Down.py b/Baekjoon Online Judge/Just_Round_Down.py new file mode 100644 index 0000000..9f7d372 --- /dev/null +++ b/Baekjoon Online Judge/Just_Round_Down.py @@ -0,0 +1,2 @@ +number = float(input()) +print(int(number)) diff --git a/Baekjoon Online Judge/Kuber.py b/Baekjoon Online Judge/Kuber.py new file mode 100644 index 0000000..5bbe550 --- /dev/null +++ b/Baekjoon Online Judge/Kuber.py @@ -0,0 +1 @@ +print(sum(i ** 3 for i in range(1, int(input()) + 1))) diff --git a/Baekjoon Online Judge/Loteria_Falha.py b/Baekjoon Online Judge/Loteria_Falha.py new file mode 100644 index 0000000..cd24a6e --- /dev/null +++ b/Baekjoon Online Judge/Loteria_Falha.py @@ -0,0 +1,13 @@ +import sys + + +for input_value in sys.stdin: + target = int(input_value) + + if target == 0: + break + + if target % 42 == 0: + print("PREMIADO") + else: + print("TENTE NOVAMENTE") diff --git a/Baekjoon Online Judge/Lucky_7.py b/Baekjoon Online Judge/Lucky_7.py new file mode 100644 index 0000000..04233ee --- /dev/null +++ b/Baekjoon Online Judge/Lucky_7.py @@ -0,0 +1,12 @@ +def solution(num): + if "7" in num and int(num) % 7 == 0: + return 3 + elif "7" in num and int(num) % 7 != 0: + return 2 + elif "7" not in num and int(num) % 7 == 0: + return 1 + else: + return 0 + + +print(solution(input())) diff --git a/Baekjoon Online Judge/Metronome.py b/Baekjoon Online Judge/Metronome.py new file mode 100644 index 0000000..be8a219 --- /dev/null +++ b/Baekjoon Online Judge/Metronome.py @@ -0,0 +1,8 @@ +def solution(n: int) -> int: + result = n / 4 + return f"{result:.2f}" + + + +n = int(input()) +print(solution(n)) \ No newline at end of file diff --git a/Baekjoon Online Judge/Micromasters.py b/Baekjoon Online Judge/Micromasters.py new file mode 100644 index 0000000..77dab6f --- /dev/null +++ b/Baekjoon Online Judge/Micromasters.py @@ -0,0 +1,2 @@ +n = int(input()) +print(n // 10) \ No newline at end of file diff --git a/Baekjoon Online Judge/Population.py b/Baekjoon Online Judge/Population.py new file mode 100644 index 0000000..79b7786 --- /dev/null +++ b/Baekjoon Online Judge/Population.py @@ -0,0 +1,5 @@ +n = int(input()) +for _ in range(n): + p, t = map(int, input().split()) + + print(p + (t // 4) - (t // 7)) diff --git a/Baekjoon Online Judge/Previous_Level.py b/Baekjoon Online Judge/Previous_Level.py new file mode 100644 index 0000000..32d8473 --- /dev/null +++ b/Baekjoon Online Judge/Previous_Level.py @@ -0,0 +1,16 @@ +_ = int(input()) +m = map(int, input().split()) + +result = [] + +for ele in m: + if ele == 300: + result.append(1) + elif ele >= 275: + result.append(2) + elif ele >= 250: + result.append(3) + else: + result.append(4) + +print(" ".join(map(str, result))) diff --git a/Baekjoon Online Judge/Quadrants.py b/Baekjoon Online Judge/Quadrants.py new file mode 100644 index 0000000..85d111f --- /dev/null +++ b/Baekjoon Online Judge/Quadrants.py @@ -0,0 +1,14 @@ +import sys + +for input_values in sys.stdin: + x, y = [float(ele) for ele in input_values.split()] + if x > 0 and y > 0: + print("Q1") + elif x < 0 and y > 0: + print("Q2") + elif x < 0 and y < 0: + print("Q3") + elif x > 0 and y < 0: + print("Q4") + else: + print("AXIS") diff --git a/Baekjoon Online Judge/RICE_SACK.py b/Baekjoon Online Judge/RICE_SACK.py new file mode 100644 index 0000000..69ee990 --- /dev/null +++ b/Baekjoon Online Judge/RICE_SACK.py @@ -0,0 +1,5 @@ +count = int(input()) + +for i in range(1, count + 1): + input_values = map(int, input().split()) + print(f"Case #{i}: {max(input_values)}") diff --git a/Baekjoon Online Judge/Reverse.c b/Baekjoon Online Judge/Reverse.c new file mode 100644 index 0000000..e69de29 diff --git a/Baekjoon Online Judge/Reverse.py b/Baekjoon Online Judge/Reverse.py new file mode 100644 index 0000000..75c4f3e --- /dev/null +++ b/Baekjoon Online Judge/Reverse.py @@ -0,0 +1,9 @@ +loop = int(input()) + +for i in range(loop): + s, i, j = input().split() + i = int(i) + j = int(j) + + print(s.replace(s[i:j], "")) + diff --git a/Baekjoon Online Judge/Rust_Study.py b/Baekjoon Online Judge/Rust_Study.py new file mode 100644 index 0000000..38ada3b --- /dev/null +++ b/Baekjoon Online Judge/Rust_Study.py @@ -0,0 +1,6 @@ +_ = input() + +plans = list(map(int, input().split())) +executions = list(map(int, input().split())) + +print(sum(plan <= execution for plan, execution in zip(plans, executions))) diff --git a/Baekjoon Online Judge/SMS_from_MCHS.py b/Baekjoon Online Judge/SMS_from_MCHS.py new file mode 100644 index 0000000..a157d9a --- /dev/null +++ b/Baekjoon Online Judge/SMS_from_MCHS.py @@ -0,0 +1,13 @@ + +today_temperature, today_wind_speed = map(int, input().split()) +tomorrow_temperature, tomorrow_wind_speed = map(int, input().split()) + + +if tomorrow_temperature < 0 and tomorrow_wind_speed >= 10: + print("A storm warning for tomorrow! Be careful and stay home if possible!") +elif tomorrow_temperature < today_temperature: + print("MCHS warns! Low temperature is expected tomorrow.") +elif tomorrow_wind_speed > today_wind_speed: + print("MCHS warns! Strong wind is expected tomorrow.") +else: + print("No message") diff --git a/Baekjoon Online Judge/SUAPC_2023_Summer.py b/Baekjoon Online Judge/SUAPC_2023_Summer.py new file mode 100644 index 0000000..add700d --- /dev/null +++ b/Baekjoon Online Judge/SUAPC_2023_Summer.py @@ -0,0 +1,15 @@ +SCORE_BOARD = { + 1: [12, 1600], + 2: [11, 894], + 3: [11, 1327], + 4: [10, 1311], + 5: [9, 1004], + 6: [9, 1178], + 7: [9, 1357], + 8: [8, 837], + 9: [7, 1055], + 10: [6, 556], + 11: [6, 773], +} + +print(" ".join(map(str, SCORE_BOARD[int(input())]))) diff --git a/Baekjoon Online Judge/SUAPC_2024_Winter.py b/Baekjoon Online Judge/SUAPC_2024_Winter.py new file mode 100644 index 0000000..7f0d893 --- /dev/null +++ b/Baekjoon Online Judge/SUAPC_2024_Winter.py @@ -0,0 +1,17 @@ +grade = int(input()) + +SUAPC_2024_WINTER_INFO = { + 1: (11, "A B C D E F G H J L M"), + 2: (9, "A C E F G H I L M"), + 3: (9, "A C E F G H I L M"), + 4: (9, "A B C E F G H L M"), + 5: (8, "A C E F G H L M"), + 6: (8, "A C E F G H L M"), + 7: (8, "A C E F G H L M"), + 8: (8, "A C E F G H L M"), + 9: (8, "A C E F G H L M"), + 10: (8, "A B C F G H L M"), +} + +print(SUAPC_2024_WINTER_INFO[grade][0]) +print(SUAPC_2024_WINTER_INFO[grade][1]) diff --git a/Baekjoon Online Judge/Schronisko.py b/Baekjoon Online Judge/Schronisko.py new file mode 100644 index 0000000..4538bb3 --- /dev/null +++ b/Baekjoon Online Judge/Schronisko.py @@ -0,0 +1,5 @@ +z = int(input()) + +for _ in range(z): + n, m = map(int, input().split()) + print(n * m // 2) diff --git a/Baekjoon Online Judge/Serca.py b/Baekjoon Online Judge/Serca.py new file mode 100644 index 0000000..7e8f5c5 --- /dev/null +++ b/Baekjoon Online Judge/Serca.py @@ -0,0 +1,31 @@ +""" +Informatycy to też ludzie, więc jak wszyscy potrzebują trochę miłości. Bajtek właśnie postanowił wyznać miłość pięknej Bajtolinie i w tym celu zamierza narysować jej N serduszek w ASCII art złożonych ze znaków małpy (@). + +Jedno serduszko wygląda następująco: + + @@@ @@@ +@ @ @ @ +@ @ @ +@ @ + @ @ + @ @ + @ @ + @ @ + @ +Bajtek chciałby, żeby serduszka były wypisane jedno pod drugim. Pomóż mu! + +Napisz program, który: wczyta liczbę N – liczbę serduszek, które Bajtek chce narysować Bajtolinie i wypisze na standardowe wyjście N serduszek w formacie opisanym powyżej. +""" + +N = int(input()) + +for _ in range(N): + print(" @@@ @@@ ") + print("@ @ @ @") + print("@ @ @") + print("@ @") + print(" @ @ ") + print(" @ @ ") + print(" @ @ ") + print(" @ @ ") + print(" @ ") diff --git a/Baekjoon Online Judge/Squares.py b/Baekjoon Online Judge/Squares.py new file mode 100644 index 0000000..2b190df --- /dev/null +++ b/Baekjoon Online Judge/Squares.py @@ -0,0 +1 @@ +print(f"The largest square has side length {int(int(input()) ** (1/2))}.") \ No newline at end of file diff --git a/Baekjoon Online Judge/Terms_of_Office.py b/Baekjoon Online Judge/Terms_of_Office.py new file mode 100644 index 0000000..0a85861 --- /dev/null +++ b/Baekjoon Online Judge/Terms_of_Office.py @@ -0,0 +1,16 @@ +def lcm(a, b, c, d): + return a * b * c * d // gcd(a, b, c, d) + + +def gcd(a, b, c, d): + return gcd(b, a % b, c, d) if b else a + + +x = int(input()) +y = int(input()) + +count = 0 +for _ in range(x, y + 1): + if count % 60 == 0: + print(f"All positions change in year {x + count}") + count += 1 diff --git a/Baekjoon Online Judge/The_Merchant_of_Venice.py b/Baekjoon Online Judge/The_Merchant_of_Venice.py new file mode 100644 index 0000000..4b401a6 --- /dev/null +++ b/Baekjoon Online Judge/The_Merchant_of_Venice.py @@ -0,0 +1,11 @@ +k = int(input()) + + +for i in range(1, k + 1): + result = 0 + n, s, d = map(int, input().split()) + for _ in range(n): + di, vi = map(int, input().split()) + if di <= s * d: + result += vi + print(f"Data Set {i}:\n{result}\n") diff --git a/Baekjoon Online Judge/The_Walking_Adam.py b/Baekjoon Online Judge/The_Walking_Adam.py new file mode 100644 index 0000000..24c1c9a --- /dev/null +++ b/Baekjoon Online Judge/The_Walking_Adam.py @@ -0,0 +1,12 @@ +case = int(input()) + +for _ in range(case): + trials = input() + + count = 0 + for trial in trials: + if trial == "D": + break + count += 1 + + print(count) \ No newline at end of file diff --git a/Baekjoon Online Judge/Triathlon.py b/Baekjoon Online Judge/Triathlon.py new file mode 100644 index 0000000..bc08616 --- /dev/null +++ b/Baekjoon Online Judge/Triathlon.py @@ -0,0 +1,15 @@ +n = int(input()) + +max_value = 0 + +for _ in range(n): + scores = list(map(int, input().split())) + a, d, g = scores + + target_value = a * (d + g) + if a == (d + g): + target_value *= 2 + + max_value = max(max_value, target_value) + +print(max_value) diff --git "a/Baekjoon Online Judge/UOS_\353\254\270\354\236\220\354\227\264.py" "b/Baekjoon Online Judge/UOS_\353\254\270\354\236\220\354\227\264.py" new file mode 100644 index 0000000..c0d8594 --- /dev/null +++ "b/Baekjoon Online Judge/UOS_\353\254\270\354\236\220\354\227\264.py" @@ -0,0 +1,10 @@ +TARGET_STRING = "UOS" + +x = int(input()) + +if x % 3 == 1: + print(TARGET_STRING[0]) +elif x % 3 == 2: + print(TARGET_STRING[1]) +else: + print(TARGET_STRING[2]) diff --git a/Baekjoon Online Judge/Welcome_to_SMUPC.py b/Baekjoon Online Judge/Welcome_to_SMUPC.py new file mode 100644 index 0000000..20a787b --- /dev/null +++ b/Baekjoon Online Judge/Welcome_to_SMUPC.py @@ -0,0 +1,8 @@ +MESSAGE = "WelcomeToSMUPC" + + +def solution(n: int) -> str: + return MESSAGE[n % len(MESSAGE) - 1] + + +print(solution(int(input()))) diff --git a/Baekjoon Online Judge/ZOAC_6.py b/Baekjoon Online Judge/ZOAC_6.py new file mode 100644 index 0000000..8340b6c --- /dev/null +++ b/Baekjoon Online Judge/ZOAC_6.py @@ -0,0 +1,8 @@ +loop = int(input()) +count = 0 +for _ in range(loop): + s = input() + if "01" in s or "OI" in s: + count += 1 + +print(count) \ No newline at end of file diff --git a/content.md b/Baekjoon Online Judge/content.md similarity index 100% rename from content.md rename to Baekjoon Online Judge/content.md diff --git "a/Baekjoon Online Judge/\303\204pplen_och_p\303\244ron.py" "b/Baekjoon Online Judge/\303\204pplen_och_p\303\244ron.py" new file mode 100644 index 0000000..427ee94 --- /dev/null +++ "b/Baekjoon Online Judge/\303\204pplen_och_p\303\244ron.py" @@ -0,0 +1,8 @@ +a, p = map(int, input().split()) + +if a * 7 > p * 13: + print("Axel") +elif a * 7 < p * 13: + print("Petra") +else: + print("lika") diff --git "a/Baekjoon Online Judge/\320\232\320\270\320\275\320\276\320\274\320\260\320\275\321\213.py" "b/Baekjoon Online Judge/\320\232\320\270\320\275\320\276\320\274\320\260\320\275\321\213.py" new file mode 100644 index 0000000..9b971e5 --- /dev/null +++ "b/Baekjoon Online Judge/\320\232\320\270\320\275\320\276\320\274\320\260\320\275\321\213.py" @@ -0,0 +1,16 @@ +max_viewing_time = list(map(int, input().split())) +mel_time = list(map(int, input().split())) + +def calculate_viewing_time(viewing_time): + trailer_time, series_time, film_time = viewing_time[0], viewing_time[1], viewing_time[2] + return trailer_time * 3 + series_time * 20 + film_time * 120 + + +if calculate_viewing_time(max_viewing_time) == calculate_viewing_time(mel_time): + print("Draw") + exit() + +if calculate_viewing_time(max_viewing_time) > calculate_viewing_time(mel_time): + print("Max") +else: + print("Mel") \ No newline at end of file diff --git "a/Baekjoon Online Judge/\320\232\320\276\320\275\320\262\320\265\320\271\320\265\321\200.py" "b/Baekjoon Online Judge/\320\232\320\276\320\275\320\262\320\265\320\271\320\265\321\200.py" new file mode 100644 index 0000000..dedab9c --- /dev/null +++ "b/Baekjoon Online Judge/\320\232\320\276\320\275\320\262\320\265\320\271\320\265\321\200.py" @@ -0,0 +1,13 @@ +_ = int(input()) +moving_histories = map(int, input().split()) + +total = sum(moving_histories) + +if total == 0: + print("Stay") + exit() + +if total > 0: + print("Right") +else: + print("Left") diff --git "a/Baekjoon Online Judge/\320\237\320\247\320\225\320\233\320\230\320\247\320\232\320\220\320\242\320\220_\320\234\320\220\320\257.py" "b/Baekjoon Online Judge/\320\237\320\247\320\225\320\233\320\230\320\247\320\232\320\220\320\242\320\220_\320\234\320\220\320\257.py" new file mode 100644 index 0000000..f5ab08b --- /dev/null +++ "b/Baekjoon Online Judge/\320\237\320\247\320\225\320\233\320\230\320\247\320\232\320\220\320\242\320\220_\320\234\320\220\320\257.py" @@ -0,0 +1,11 @@ +a, b, c = map(int, input().split()) + +avg = (a + b + c) // 3 +res = 0 + +res += c - avg +b += c - avg + +res += b - avg + +print(res) diff --git "a/Baekjoon Online Judge/\320\240\320\276\320\261\320\270\320\275\320\267\320\276\320\275_\320\232\321\200\321\203\320\267\320\276.py" "b/Baekjoon Online Judge/\320\240\320\276\320\261\320\270\320\275\320\267\320\276\320\275_\320\232\321\200\321\203\320\267\320\276.py" new file mode 100644 index 0000000..3a71fb1 --- /dev/null +++ "b/Baekjoon Online Judge/\320\240\320\276\320\261\320\270\320\275\320\267\320\276\320\275_\320\232\321\200\321\203\320\267\320\276.py" @@ -0,0 +1,6 @@ +def solution(num): + return "V" * (num // 5) + "I" * (num % 5) + + +num = int(input()) +print(solution(num)) diff --git "a/Baekjoon Online Judge/\320\241\321\207\320\260\321\201\321\202\321\214\320\265_\320\234\320\270\321\201\321\202\320\265\321\200\320\260_\320\221\320\270\320\275\320\260.py" "b/Baekjoon Online Judge/\320\241\321\207\320\260\321\201\321\202\321\214\320\265_\320\234\320\270\321\201\321\202\320\265\321\200\320\260_\320\221\320\270\320\275\320\260.py" new file mode 100644 index 0000000..4d7da94 --- /dev/null +++ "b/Baekjoon Online Judge/\320\241\321\207\320\260\321\201\321\202\321\214\320\265_\320\234\320\270\321\201\321\202\320\265\321\200\320\260_\320\221\320\270\320\275\320\260.py" @@ -0,0 +1,8 @@ +count = int(input()) +numbers = list(map(int, input().split())) + +is_happiness_score = sum(1 if number % 2 == 0 else -1 for number in numbers) > 0 +if is_happiness_score: + print("Happy") +else: + print("Sad") diff --git "a/Baekjoon Online Judge/\343\202\242\343\202\244\343\202\271\343\202\257\343\203\252\343\203\274\343\203\240_Ice_Cream.py" "b/Baekjoon Online Judge/\343\202\242\343\202\244\343\202\271\343\202\257\343\203\252\343\203\274\343\203\240_Ice_Cream.py" new file mode 100644 index 0000000..0de362d --- /dev/null +++ "b/Baekjoon Online Judge/\343\202\242\343\202\244\343\202\271\343\202\257\343\203\252\343\203\274\343\203\240_Ice_Cream.py" @@ -0,0 +1,11 @@ +from math import ceil + + +s = int(input()) +a = int(input()) +b = int(input()) + +if a >= s: + print(250) +else: + print(int(250 + (ceil((s - a) / b) * 100))) diff --git "a/Baekjoon Online Judge/\343\202\276\343\203\255\347\233\256_Same_Numbers.py" "b/Baekjoon Online Judge/\343\202\276\343\203\255\347\233\256_Same_Numbers.py" new file mode 100644 index 0000000..12cf48d --- /dev/null +++ "b/Baekjoon Online Judge/\343\202\276\343\203\255\347\233\256_Same_Numbers.py" @@ -0,0 +1,2 @@ +number: str = input() +print(1) if number[0] == number[1] else print(0) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\343\203\226\343\203\251\343\203\203\343\202\257\343\202\270\343\203\243\343\203\203\343\202\257_Blackjack.py" "b/Baekjoon Online Judge/\343\203\226\343\203\251\343\203\203\343\202\257\343\202\270\343\203\243\343\203\203\343\202\257_Blackjack.py" new file mode 100644 index 0000000..46861da --- /dev/null +++ "b/Baekjoon Online Judge/\343\203\226\343\203\251\343\203\203\343\202\257\343\202\270\343\203\243\343\203\203\343\202\257_Blackjack.py" @@ -0,0 +1,8 @@ +a = int(input()) +b = int(input()) +c = int(input()) + +if a + b + c <= 21: + print(1) +else: + print(0) diff --git "a/Baekjoon Online Judge/\344\270\211\346\226\271\346\257\224\350\274\203_Three_Way_Comparison.py" "b/Baekjoon Online Judge/\344\270\211\346\226\271\346\257\224\350\274\203_Three_Way_Comparison.py" new file mode 100644 index 0000000..cd6233c --- /dev/null +++ "b/Baekjoon Online Judge/\344\270\211\346\226\271\346\257\224\350\274\203_Three_Way_Comparison.py" @@ -0,0 +1,9 @@ +a = int(input()) +b = int(input()) + +if a < b: + print(-1) +elif a == b: + print(0) +else: + print(1) diff --git "a/Baekjoon Online Judge/\345\210\206_Minutes.py" "b/Baekjoon Online Judge/\345\210\206_Minutes.py" new file mode 100644 index 0000000..ba145a6 --- /dev/null +++ "b/Baekjoon Online Judge/\345\210\206_Minutes.py" @@ -0,0 +1,4 @@ +hour = int(input()) +minute = int(input()) + +print(hour * 60 + minute) diff --git "a/Baekjoon Online Judge/\345\270\260\347\234\201_Homecoming.py" "b/Baekjoon Online Judge/\345\270\260\347\234\201_Homecoming.py" new file mode 100644 index 0000000..5762ac9 --- /dev/null +++ "b/Baekjoon Online Judge/\345\270\260\347\234\201_Homecoming.py" @@ -0,0 +1,6 @@ +a, b, c = map(int, input().split()) + +if a <= c < b: + print(1) +else: + print(0) diff --git "a/Baekjoon Online Judge/\345\276\222\347\253\266\350\265\260_Footrace.py" "b/Baekjoon Online Judge/\345\276\222\347\253\266\350\265\260_Footrace.py" new file mode 100644 index 0000000..a89b574 --- /dev/null +++ "b/Baekjoon Online Judge/\345\276\222\347\253\266\350\265\260_Footrace.py" @@ -0,0 +1,4 @@ +t = int(input()) +v = int(input()) + +print(t * v) diff --git "a/Baekjoon Online Judge/\346\211\200\346\214\201\351\207\221_Money_On_Me.py" "b/Baekjoon Online Judge/\346\211\200\346\214\201\351\207\221_Money_On_Me.py" new file mode 100644 index 0000000..e672ed9 --- /dev/null +++ "b/Baekjoon Online Judge/\346\211\200\346\214\201\351\207\221_Money_On_Me.py" @@ -0,0 +1,4 @@ +a = int(input()) +b = int(input()) + +print(a * 1000 + b * 10000) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\346\231\202\351\226\223_Hour.py" "b/Baekjoon Online Judge/\346\231\202\351\226\223_Hour.py" new file mode 100644 index 0000000..d9b4618 --- /dev/null +++ "b/Baekjoon Online Judge/\346\231\202\351\226\223_Hour.py" @@ -0,0 +1,2 @@ +day = int(input()) +print(day * 24) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\346\234\253\345\260\276\343\201\256\346\226\207\345\255\227_Last_Letter.py" "b/Baekjoon Online Judge/\346\234\253\345\260\276\343\201\256\346\226\207\345\255\227_Last_Letter.py" new file mode 100644 index 0000000..bd1064c --- /dev/null +++ "b/Baekjoon Online Judge/\346\234\253\345\260\276\343\201\256\346\226\207\345\255\227_Last_Letter.py" @@ -0,0 +1,7 @@ +n = int(input()) +s = input() + +if s[-1] == "G": + print(s[:-1]) +else: + print(s + "G") diff --git "a/Baekjoon Online Judge/\346\236\234\347\211\251_Fruit.py" "b/Baekjoon Online Judge/\346\236\234\347\211\251_Fruit.py" new file mode 100644 index 0000000..518b06b --- /dev/null +++ "b/Baekjoon Online Judge/\346\236\234\347\211\251_Fruit.py" @@ -0,0 +1,4 @@ +x = int(input()) +y = int(input()) + +print(x + y + 3) diff --git "a/Baekjoon Online Judge/\346\257\215\351\237\263\343\202\222\346\225\260\343\201\210\343\202\213_Counting_Vowels.py" "b/Baekjoon Online Judge/\346\257\215\351\237\263\343\202\222\346\225\260\343\201\210\343\202\213_Counting_Vowels.py" new file mode 100644 index 0000000..03a4f55 --- /dev/null +++ "b/Baekjoon Online Judge/\346\257\215\351\237\263\343\202\222\346\225\260\343\201\210\343\202\213_Counting_Vowels.py" @@ -0,0 +1,10 @@ +VOWELS = "aeiou" + + +def solution(input_word: str) -> int: + return sum(character in VOWELS for character in input_word) + + +if __name__ == "__main__": + _ = int(input()) + print(solution(input())) diff --git "a/Baekjoon Online Judge/\347\201\253\346\233\234\346\227\245_Tuesday.py" "b/Baekjoon Online Judge/\347\201\253\346\233\234\346\227\245_Tuesday.py" new file mode 100644 index 0000000..9c2cb42 --- /dev/null +++ "b/Baekjoon Online Judge/\347\201\253\346\233\234\346\227\245_Tuesday.py" @@ -0,0 +1,6 @@ +after_day = int(input()) + +if after_day % 7 == 2: + print("1") +else: + print("0") diff --git "a/Baekjoon Online Judge/\347\237\255\351\207\235_Hour_Hand.py" "b/Baekjoon Online Judge/\347\237\255\351\207\235_Hour_Hand.py" new file mode 100644 index 0000000..ab03ed2 --- /dev/null +++ "b/Baekjoon Online Judge/\347\237\255\351\207\235_Hour_Hand.py" @@ -0,0 +1,9 @@ +a = int(input()) +b = int(input()) + +result = (a + b) % 12 + +if result == 0: + print(12) +else: + print(result) diff --git "a/Baekjoon Online Judge/\347\247\273\345\213\225_Moving.py" "b/Baekjoon Online Judge/\347\247\273\345\213\225_Moving.py" new file mode 100644 index 0000000..de40cbe --- /dev/null +++ "b/Baekjoon Online Judge/\347\247\273\345\213\225_Moving.py" @@ -0,0 +1,8 @@ +x = int(input()) +y = int(input()) +z = int(input()) + +if (x + y) <= (z * 60 + 30) / 60: + print("1") +else: + print("0") diff --git "a/Baekjoon Online Judge/\350\250\210\347\256\227_Calculation.py" "b/Baekjoon Online Judge/\350\250\210\347\256\227_Calculation.py" new file mode 100644 index 0000000..5df50fb --- /dev/null +++ "b/Baekjoon Online Judge/\350\250\210\347\256\227_Calculation.py" @@ -0,0 +1,4 @@ +a, b = map(int, input().split()) + +print(max(a + b, a - b)) +print(min(a + b, a - b)) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\351\211\233\347\255\206_2_Pencils_2.py" "b/Baekjoon Online Judge/\351\211\233\347\255\206_2_Pencils_2.py" new file mode 100644 index 0000000..4b7a764 --- /dev/null +++ "b/Baekjoon Online Judge/\351\211\233\347\255\206_2_Pencils_2.py" @@ -0,0 +1,2 @@ +a = int(input()) +print(a // 5) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\351\243\264\343\201\256\350\242\213\350\251\260\343\202\201_Drops_Packing.py" "b/Baekjoon Online Judge/\351\243\264\343\201\256\350\242\213\350\251\260\343\202\201_Drops_Packing.py" new file mode 100644 index 0000000..25759c8 --- /dev/null +++ "b/Baekjoon Online Judge/\351\243\264\343\201\256\350\242\213\350\251\260\343\202\201_Drops_Packing.py" @@ -0,0 +1,5 @@ +a = int(input()) +b = int(input()) +c = int(input()) + +print(a * b + c) diff --git "a/Baekjoon Online Judge/\352\260\200\355\235\254\354\231\200_4_\354\213\234\352\260\204\354\235\230_\353\262\275_1.py" "b/Baekjoon Online Judge/\352\260\200\355\235\254\354\231\200_4_\354\213\234\352\260\204\354\235\230_\353\262\275_1.py" new file mode 100644 index 0000000..b28aae9 --- /dev/null +++ "b/Baekjoon Online Judge/\352\260\200\355\235\254\354\231\200_4_\354\213\234\352\260\204\354\235\230_\353\262\275_1.py" @@ -0,0 +1,7 @@ +s_ab = int(input()) +f_ab = int(input()) + +if s_ab <= f_ab: + print("high speed rail") +else: + print("flight") diff --git "a/Baekjoon Online Judge/\352\260\200\355\235\254\354\231\200_\355\201\264\353\237\275_\354\230\244\353\224\224\354\205\230_1.py" "b/Baekjoon Online Judge/\352\260\200\355\235\254\354\231\200_\355\201\264\353\237\275_\354\230\244\353\224\224\354\205\230_1.py" new file mode 100644 index 0000000..0922434 --- /dev/null +++ "b/Baekjoon Online Judge/\352\260\200\355\235\254\354\231\200_\355\201\264\353\237\275_\354\230\244\353\224\224\354\205\230_1.py" @@ -0,0 +1,14 @@ +input_value = input().split() +lv, panjung = int(input_value[0]), input_value[1] + +if panjung == "miss": + print(0) +elif panjung == "bad": + print(lv * 200) +elif panjung == "cool": + print(lv * 400) +elif panjung == "great": + print(lv * 600) +else: + print(1000 * int(lv)) + \ No newline at end of file diff --git "a/Baekjoon Online Judge/\352\260\220\353\247\210\354\204\240\354\235\204_\353\247\236\354\235\200_\354\273\264\355\223\250\355\204\260.py" "b/Baekjoon Online Judge/\352\260\220\353\247\210\354\204\240\354\235\204_\353\247\236\354\235\200_\354\273\264\355\223\250\355\204\260.py" new file mode 100644 index 0000000..54e89ec --- /dev/null +++ "b/Baekjoon Online Judge/\352\260\220\353\247\210\354\204\240\354\235\204_\353\247\236\354\235\200_\354\273\264\355\223\250\355\204\260.py" @@ -0,0 +1,12 @@ +cat_picture = [input().split() for _ in range(15)] + +for row in cat_picture: + if "w" in row: + print("chunbae") + break + elif "b" in row: + print("nabi") + break + elif "g" in row: + print("yeongcheol") + break diff --git "a/Baekjoon Online Judge/\352\260\225\353\213\271_\353\214\200\352\264\200.py" "b/Baekjoon Online Judge/\352\260\225\353\213\271_\353\214\200\352\264\200.py" new file mode 100644 index 0000000..273247d --- /dev/null +++ "b/Baekjoon Online Judge/\352\260\225\353\213\271_\353\214\200\352\264\200.py" @@ -0,0 +1,10 @@ +max_value = 0 +max_seminar = "" +for _ in range(7): + input_value = input().split() + seminar, count = input_value[0], int(input_value[1]) + if count > max_value: + max_value = count + max_seminar = seminar + +print(max_seminar) diff --git "a/Baekjoon Online Judge/\352\260\234\355\221\234.py" "b/Baekjoon Online Judge/\352\260\234\355\221\234.py" new file mode 100644 index 0000000..3831b0f --- /dev/null +++ "b/Baekjoon Online Judge/\352\260\234\355\221\234.py" @@ -0,0 +1,13 @@ +t = int(input()) + +for _ in range(t): + result = [] + + vote = int(input()) + five_votes, one_vote = divmod(vote, 5) + + for _ in range(five_votes): + result.append("++++") + result.append("|" * one_vote) + + print(" ".join(result)) diff --git "a/Baekjoon Online Judge/\352\264\200\352\263\265_\354\226\264\354\260\214\355\225\230\354\227\254_\353\252\251\353\247\214_\354\230\244\354\205\250\354\206\214.py" "b/Baekjoon Online Judge/\352\264\200\352\263\265_\354\226\264\354\260\214\355\225\230\354\227\254_\353\252\251\353\247\214_\354\230\244\354\205\250\354\206\214.py" new file mode 100644 index 0000000..3013763 --- /dev/null +++ "b/Baekjoon Online Judge/\352\264\200\352\263\265_\354\226\264\354\260\214\355\225\230\354\227\254_\353\252\251\353\247\214_\354\230\244\354\205\250\354\206\214.py" @@ -0,0 +1,3 @@ +loop = int(input()) +targets = [input() for _ in range(loop)] +print(next(target for target in targets if "S" in target)) diff --git "a/Baekjoon Online Judge/\352\267\270\352\262\214_\353\254\264\354\212\250_\354\275\224\353\223\234\353\213\210.py" "b/Baekjoon Online Judge/\352\267\270\352\262\214_\353\254\264\354\212\250_\354\275\224\353\223\234\353\213\210.py" new file mode 100644 index 0000000..27166a3 --- /dev/null +++ "b/Baekjoon Online Judge/\352\267\270\352\262\214_\353\254\264\354\212\250_\354\275\224\353\223\234\353\213\210.py" @@ -0,0 +1,6 @@ +code = input() + +if code[0] == code[-1] == '"' and len(code[1:-1]) > 0: + print(code[1:-1]) +else: + print("CE") diff --git "a/Baekjoon Online Judge/\352\270\200\353\241\234\353\262\214_\355\217\254\353\213\211\354\212\244.py" "b/Baekjoon Online Judge/\352\270\200\353\241\234\353\262\214_\355\217\254\353\213\211\354\212\244.py" new file mode 100644 index 0000000..cd07a8b --- /dev/null +++ "b/Baekjoon Online Judge/\352\270\200\353\241\234\353\262\214_\355\217\254\353\213\211\354\212\244.py" @@ -0,0 +1,13 @@ +s1 = input() +s2 = input() +s3 = input() + +FOR_GLOBAL = {"l", "k", "p"} + +condition_1 = s1[0] in FOR_GLOBAL and s2[0] in FOR_GLOBAL and s3[0] in FOR_GLOBAL +condition_2 = set(f"{s1[0]}{s2[0]}{s3[0]}") == set(FOR_GLOBAL) + +if condition_1 and condition_2: + print("GLOBAL") +else: + print("PONIX") diff --git "a/Baekjoon Online Judge/\353\205\270\355\212\270\353\266\201_\354\204\270_\353\214\200\353\245\274_\352\260\200\354\247\200\352\263\240_\354\231\224\353\213\244.py" "b/Baekjoon Online Judge/\353\205\270\355\212\270\353\266\201_\354\204\270_\353\214\200\353\245\274_\352\260\200\354\247\200\352\263\240_\354\231\224\353\213\244.py" new file mode 100644 index 0000000..b83c84c --- /dev/null +++ "b/Baekjoon Online Judge/\353\205\270\355\212\270\353\266\201_\354\204\270_\353\214\200\353\245\274_\352\260\200\354\247\200\352\263\240_\354\231\224\353\213\244.py" @@ -0,0 +1,2 @@ +t1, t2 = map(int, input().split()) +print(min(t1, t2)) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\353\223\261\352\265\220.py" "b/Baekjoon Online Judge/\353\223\261\352\265\220.py" new file mode 100644 index 0000000..899ce4c --- /dev/null +++ "b/Baekjoon Online Judge/\353\223\261\352\265\220.py" @@ -0,0 +1,12 @@ +n, x = map(int, input().split()) + +result = [] + +for _ in range(n): + s, t = map(int, input().split()) + if s + t <= x: + result.append(s) +try: + print(max(result)) +except ValueError: + print(-1) diff --git "a/Baekjoon Online Judge/\353\235\274\353\251\264_\352\263\265\354\213\235.py" "b/Baekjoon Online Judge/\353\235\274\353\251\264_\352\263\265\354\213\235.py" new file mode 100644 index 0000000..d0d4ea0 --- /dev/null +++ "b/Baekjoon Online Judge/\353\235\274\353\251\264_\352\263\265\354\213\235.py" @@ -0,0 +1,8 @@ +def solution(a: int, b: int, x: int) -> int: + return a * (x - 1) + b + + +loop = int(input()) +for _ in range(loop): + a, b, x = list(map(int, input().split())) + print(solution(a, b, x)) diff --git "a/Baekjoon Online Judge/\353\241\234\353\230\220.py" "b/Baekjoon Online Judge/\353\241\234\353\230\220.py" new file mode 100644 index 0000000..24a8726 --- /dev/null +++ "b/Baekjoon Online Judge/\353\241\234\353\230\220.py" @@ -0,0 +1,25 @@ +import sys + +from itertools import combinations + +LOTTO_COUNT = 6 + + +def solution(s: list[int]): + result = [] + + for combination in combinations(s, LOTTO_COUNT): + result.append(" ".join(map(str, combination))) + + return "\n".join(result) + + +if __name__ == "__main__": + for line in sys.stdin: + if not line.strip(): + continue + input_values = list(map(int, line.split())) + k, *s = input_values + if k == 0: + break + print(solution(s), end="\n\n") diff --git "a/Baekjoon Online Judge/\353\257\274\354\243\274\354\243\274\354\235\230.py" "b/Baekjoon Online Judge/\353\257\274\354\243\274\354\243\274\354\235\230.py" new file mode 100644 index 0000000..617761f --- /dev/null +++ "b/Baekjoon Online Judge/\353\257\274\354\243\274\354\243\274\354\235\230.py" @@ -0,0 +1,2 @@ +n, _ = map(int, input().split()) +print(sum(1 for problem in [input() for _ in range(n)] if problem.count("O") > problem.count("X"))) diff --git "a/Baekjoon Online Judge/\353\270\214\354\213\244\354\235\264\354\231\200_\354\271\234\352\265\254\352\260\200_\353\220\230\352\263\240_\354\213\266\354\226\264.py" "b/Baekjoon Online Judge/\353\270\214\354\213\244\354\235\264\354\231\200_\354\271\234\352\265\254\352\260\200_\353\220\230\352\263\240_\354\213\266\354\226\264.py" new file mode 100644 index 0000000..58fc4ba --- /dev/null +++ "b/Baekjoon Online Judge/\353\270\214\354\213\244\354\235\264\354\231\200_\354\271\234\352\265\254\352\260\200_\353\220\230\352\263\240_\354\213\266\354\226\264.py" @@ -0,0 +1,12 @@ +a, b = map(int, input().split()) +k, x = map(int, input().split()) + +friend_range = {i for i in range(a, b + 1)} +bsil_enable_friend_range = {i for i in range(k - x, k + x + 1)} + +intersection = friend_range & bsil_enable_friend_range + +if intersection: + print(len(intersection)) +else: + print("IMPOSSIBLE") diff --git "a/Baekjoon Online Judge/\354\202\254\353\236\221\354\235\200_\352\263\240\353\240\244\353\214\200\354\236\205\353\213\210\353\213\244.py" "b/Baekjoon Online Judge/\354\202\254\353\236\221\354\235\200_\352\263\240\353\240\244\353\214\200\354\236\205\353\213\210\353\213\244.py" new file mode 100644 index 0000000..0daa1f6 --- /dev/null +++ "b/Baekjoon Online Judge/\354\202\254\353\236\221\354\235\200_\352\263\240\353\240\244\353\214\200\354\236\205\353\213\210\353\213\244.py" @@ -0,0 +1,5 @@ +TARGET_STRING = "LoveisKoreaUniversity" + +count = int(input()) + +print(" ".join([TARGET_STRING] * count)) diff --git "a/Baekjoon Online Judge/\354\202\274\352\260\201\355\230\225.py" "b/Baekjoon Online Judge/\354\202\274\352\260\201\355\230\225.py" new file mode 100644 index 0000000..0a72239 --- /dev/null +++ "b/Baekjoon Online Judge/\354\202\274\352\260\201\355\230\225.py" @@ -0,0 +1,6 @@ +def solution(w: int, h: int) -> str: + return f"{w * h / 2:.1f}" + + +w, h = list(map(int, input().split())) +print(solution(w, h)) diff --git "a/Baekjoon Online Judge/\354\204\240\353\254\274.py" "b/Baekjoon Online Judge/\354\204\240\353\254\274.py" new file mode 100644 index 0000000..ddccadf --- /dev/null +++ "b/Baekjoon Online Judge/\354\204\240\353\254\274.py" @@ -0,0 +1,4 @@ +_, x = map(int, input().split()) +a = list(map(int, input().split())) +print(min(ele[0] * x + ele[1] * x for ele in list(zip(a, a[1:])))) + \ No newline at end of file diff --git "a/Baekjoon Online Judge/\354\204\270\354\240\234\352\263\261\354\235\230_\355\225\251.py" "b/Baekjoon Online Judge/\354\204\270\354\240\234\352\263\261\354\235\230_\355\225\251.py" new file mode 100644 index 0000000..eef1ae7 --- /dev/null +++ "b/Baekjoon Online Judge/\354\204\270\354\240\234\352\263\261\354\235\230_\355\225\251.py" @@ -0,0 +1,16 @@ +def solution_line_1(n: int) -> int: + return sum(i for i in range(1, n + 1)) + + +def solution_line_2(n: int) -> int: + return solution_line_1(n) ** 2 + + +def solution_line_3(n: int) -> int: + return sum(i**3 for i in range(1, n + 1)) + + +n = int(input()) +print(solution_line_1(n)) +print(solution_line_2(n)) +print(solution_line_3(n)) diff --git "a/Baekjoon Online Judge/\354\212\244\354\234\204\355\212\270\354\275\230_\352\260\200\352\262\251_\352\265\254\355\225\230\352\270\260.py" "b/Baekjoon Online Judge/\354\212\244\354\234\204\355\212\270\354\275\230_\352\260\200\352\262\251_\352\265\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..2dd1138 --- /dev/null +++ "b/Baekjoon Online Judge/\354\212\244\354\234\204\355\212\270\354\275\230_\352\260\200\352\262\251_\352\265\254\355\225\230\352\270\260.py" @@ -0,0 +1,9 @@ +VAT = 0.1 + + +def solution(b: int) -> int: + return round(b / (1 + VAT)) + + +b = int(input()) +print(solution(b)) diff --git "a/Baekjoon Online Judge/\354\225\210\353\260\226_\353\260\226\354\225\210_\352\263\204\353\213\250_\354\227\255\352\263\204\353\213\250.py" "b/Baekjoon Online Judge/\354\225\210\353\260\226_\353\260\226\354\225\210_\352\263\204\353\213\250_\354\227\255\352\263\204\353\213\250.py" new file mode 100644 index 0000000..03d1f91 --- /dev/null +++ "b/Baekjoon Online Judge/\354\225\210\353\260\226_\353\260\226\354\225\210_\352\263\204\353\213\250_\354\227\255\352\263\204\353\213\250.py" @@ -0,0 +1,10 @@ +result = { + "fdsajkl;": "in-out", + "jkl;fdsa": "in-out", + "asdf;lkj": "out-in", + ";lkjasdf": "out-in", + "asdfjkl;": "stairs", + ";lkjfdsa": "reverse", +}.get(input(), "molu") + +print(result) diff --git "a/Baekjoon Online Judge/\354\225\224\355\230\270_\353\247\214\353\223\244\352\270\260.py" "b/Baekjoon Online Judge/\354\225\224\355\230\270_\353\247\214\353\223\244\352\270\260.py" new file mode 100644 index 0000000..eaacd7d --- /dev/null +++ "b/Baekjoon Online Judge/\354\225\224\355\230\270_\353\247\214\353\223\244\352\270\260.py" @@ -0,0 +1,30 @@ +from itertools import combinations + +VOWELS = "aeiou" +CONSONANTS = "bcdfghjklmnpqrstvwxyz" + + +def solution(l: int, target_alphabets: list[str]): + sorted_target_alphabets = sorted(target_alphabets) + + result = [] + + for combination in combinations(sorted_target_alphabets, l): + if not _validate_conditions(combination): + continue + result.append("".join(combination)) + + return "\n".join(result) + + +def _validate_conditions(combination: list[str]) -> bool: + return ( + len(set(combination) & set(VOWELS)) >= 1 + and len(set(combination) & set(CONSONANTS)) >= 2 + ) + + +if __name__ == "__main__": + l, _ = list(map(int, input().split())) + target_alphabets = input().split() + print(solution(l, target_alphabets)) diff --git "a/Baekjoon Online Judge/\354\227\230\353\246\254\354\212\244_\355\212\270\353\236\231_\353\247\244\354\271\255.py" "b/Baekjoon Online Judge/\354\227\230\353\246\254\354\212\244_\355\212\270\353\236\231_\353\247\244\354\271\255.py" new file mode 100644 index 0000000..823b661 --- /dev/null +++ "b/Baekjoon Online Judge/\354\227\230\353\246\254\354\212\244_\355\212\270\353\236\231_\353\247\244\354\271\255.py" @@ -0,0 +1,5 @@ +n = int(input()) +tracks = input().split() +target_apply_track = input() + +print(tracks.count(target_apply_track)) diff --git "a/Baekjoon Online Judge/\354\234\240\354\271\230\354\233\220\354\203\235_\355\214\214\353\214\225\354\235\264_\353\217\214\353\263\264\352\270\260.py" "b/Baekjoon Online Judge/\354\234\240\354\271\230\354\233\220\354\203\235_\355\214\214\353\214\225\354\235\264_\353\217\214\353\263\264\352\270\260.py" new file mode 100644 index 0000000..25d2e6c --- /dev/null +++ "b/Baekjoon Online Judge/\354\234\240\354\271\230\354\233\220\354\203\235_\355\214\214\353\214\225\354\235\264_\353\217\214\353\263\264\352\270\260.py" @@ -0,0 +1,8 @@ +t = int(input()) +_ = int(input()) +f = list(map(int, input().split())) + +if t <= sum(f): + print("Padaeng_i Happy") +else: + print("Padaeng_i Cry") diff --git "a/Baekjoon Online Judge/\354\235\264_\353\214\200\355\232\214\353\212\224_\354\235\264\354\240\234_\354\240\234_\352\262\201\353\213\210\353\213\244.py" "b/Baekjoon Online Judge/\354\235\264_\353\214\200\355\232\214\353\212\224_\354\235\264\354\240\234_\354\240\234_\352\262\201\353\213\210\353\213\244.py" new file mode 100644 index 0000000..ad014b2 --- /dev/null +++ "b/Baekjoon Online Judge/\354\235\264_\353\214\200\355\232\214\353\212\224_\354\235\264\354\240\234_\354\240\234_\352\262\201\353\213\210\353\213\244.py" @@ -0,0 +1,3 @@ +a, p, c = map(int, input().split()) + +print(max(a + c, p)) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\354\235\264_\353\263\204\354\235\200_\353\254\264\354\212\250_\354\203\211\354\235\274\352\271\214.py" "b/Baekjoon Online Judge/\354\235\264_\353\263\204\354\235\200_\353\254\264\354\212\250_\354\203\211\354\235\274\352\271\214.py" new file mode 100644 index 0000000..64e796a --- /dev/null +++ "b/Baekjoon Online Judge/\354\235\264_\353\263\204\354\235\200_\353\254\264\354\212\250_\354\203\211\354\235\274\352\271\214.py" @@ -0,0 +1,32 @@ +""" +빨간색: 620nm 이상 780nm 이하 +주황색: 590nm 이상 620nm 미만 +노란색: 570nm 이상 590nm 미만 +초록색: 495nm 이상 570nm 미만 +파란색: 450nm 이상 495nm 미만 +남색: 425nm 이상 450nm 미만 +보라색: 380nm 이상 425nm 미만 +""" + + +def solution(wavelength: int) -> str: + if 620 <= wavelength <= 780: + return "Red" + elif 590 <= wavelength < 620: + return "Orange" + elif 570 <= wavelength < 590: + return "Yellow" + elif 495 <= wavelength < 570: + return "Green" + elif 450 <= wavelength < 495: + return "Blue" + elif 425 <= wavelength < 450: + return "Indigo" + elif 380 <= wavelength < 425: + return "Violet" + else: + return "Invalid" + + +wavelength = int(input()) +print(solution(wavelength)) diff --git "a/Baekjoon Online Judge/\354\236\254\354\210\230\352\260\225.py" "b/Baekjoon Online Judge/\354\236\254\354\210\230\352\260\225.py" new file mode 100644 index 0000000..b8774ff --- /dev/null +++ "b/Baekjoon Online Judge/\354\236\254\354\210\230\352\260\225.py" @@ -0,0 +1,13 @@ +retrial_subject_code = input() +available_subject_count = int(input()) + + +count = 0 +for _ in range(available_subject_count): + input_subject_code = input() + target = retrial_subject_code[:5] + if input_subject_code[:5] == target: + count += 1 + +print(count) + diff --git "a/Baekjoon Online Judge/\354\240\225\353\263\264\353\263\264\355\230\270\355\225\231\353\266\200_\353\217\231\354\225\204\353\246\254_\354\206\214\352\260\234.py" "b/Baekjoon Online Judge/\354\240\225\353\263\264\353\263\264\355\230\270\355\225\231\353\266\200_\353\217\231\354\225\204\353\246\254_\354\206\214\352\260\234.py" new file mode 100644 index 0000000..d7a6810 --- /dev/null +++ "b/Baekjoon Online Judge/\354\240\225\353\263\264\353\263\264\355\230\270\355\225\231\353\266\200_\353\217\231\354\225\204\353\246\254_\354\206\214\352\260\234.py" @@ -0,0 +1,15 @@ +def solution(character: str) -> str: + if character == "M": + return "MatKor" + elif character == "W": + return "WiCys" + elif character == "C": + return "CyKor" + elif character == "A": + return "AlKor" + else: + return "$clear" + + +character = input() +print(solution(character)) diff --git "a/Baekjoon Online Judge/\354\240\225\353\263\264\354\204\254\354\235\230_\353\214\200\354\244\221\352\265\220\355\206\265.py" "b/Baekjoon Online Judge/\354\240\225\353\263\264\354\204\254\354\235\230_\353\214\200\354\244\221\352\265\220\355\206\265.py" new file mode 100644 index 0000000..ff9cee4 --- /dev/null +++ "b/Baekjoon Online Judge/\354\240\225\353\263\264\354\204\254\354\235\230_\353\214\200\354\244\221\352\265\220\355\206\265.py" @@ -0,0 +1,11 @@ +def solution(a: int, b: int) -> str: + if a < b: + return "Bus" + elif a > b: + return "Subway" + else: + return "Anything" + + +_, a, b = list(map(int, input().split())) +print(solution(a, b)) diff --git "a/Baekjoon Online Judge/\354\244\200\354\230\201\354\235\264\354\235\230_\353\223\261\352\270\211.py" "b/Baekjoon Online Judge/\354\244\200\354\230\201\354\235\264\354\235\230_\353\223\261\352\270\211.py" new file mode 100644 index 0000000..5358ec2 --- /dev/null +++ "b/Baekjoon Online Judge/\354\244\200\354\230\201\354\235\264\354\235\230_\353\223\261\352\270\211.py" @@ -0,0 +1,30 @@ +from math import floor + +n, k = map(int, input().split()) +ranks = list(map(int, input().split())) + +result = [] + +for rank in ranks: + percentage = floor(rank / n * 10**2) / 10**2 + + if 0 <= percentage <= 0.04: + result.append(1) + elif 0.04 < percentage <= 0.11: + result.append(2) + elif 0.11 < percentage <= 0.23: + result.append(3) + elif 0.23 < percentage <= 0.40: + result.append(4) + elif 0.40 < percentage <= 0.60: + result.append(5) + elif 0.60 < percentage <= 0.77: + result.append(6) + elif 0.77 < percentage <= 0.89: + result.append(7) + elif 0.89 < percentage <= 0.96: + result.append(8) + else: + result.append(9) + +print(*result) diff --git "a/Baekjoon Online Judge/\354\247\200\355\217\220_\354\204\270\352\270\260.py" "b/Baekjoon Online Judge/\354\247\200\355\217\220_\354\204\270\352\270\260.py" new file mode 100644 index 0000000..b42c6a7 --- /dev/null +++ "b/Baekjoon Online Judge/\354\247\200\355\217\220_\354\204\270\352\270\260.py" @@ -0,0 +1,19 @@ +loop = int(input()) + +result = [] + +for _ in range(loop): + width, _ = map(int, input().split()) + + if width == 136: + price = 1000 + elif width == 142: + price = 5000 + elif width == 148: + price = 10000 + else: + price = 50000 + + result.append(price) + +print(sum(result)) diff --git "a/Baekjoon Online Judge/\354\247\204\355\235\245\354\233\220_\354\204\270\353\257\270\353\202\230.py" "b/Baekjoon Online Judge/\354\247\204\355\235\245\354\233\220_\354\204\270\353\257\270\353\202\230.py" new file mode 100644 index 0000000..8cbdcf6 --- /dev/null +++ "b/Baekjoon Online Judge/\354\247\204\355\235\245\354\233\220_\354\204\270\353\257\270\353\202\230.py" @@ -0,0 +1,19 @@ +SEMINAR = { + "Algorithm": "204", + "DataAnalysis": "207", + "ArtificialIntelligence": "302", + "CyberSecurity": "B101", + "Network": "303", + "Startup": "501", + "TestStrategy": "105", +} + + +def solution(key: str) -> str: + return SEMINAR[key] + + +loop = int(input()) +for _ in range(loop): + key = input() + print(solution(key)) diff --git "a/Baekjoon Online Judge/\354\262\264\354\212\244_\354\264\210\353\263\264_\353\270\214\354\213\244\354\235\264.py" "b/Baekjoon Online Judge/\354\262\264\354\212\244_\354\264\210\353\263\264_\353\270\214\354\213\244\354\235\264.py" new file mode 100644 index 0000000..4b3b358 --- /dev/null +++ "b/Baekjoon Online Judge/\354\262\264\354\212\244_\354\264\210\353\263\264_\353\270\214\354\213\244\354\235\264.py" @@ -0,0 +1,55 @@ +from dataclasses import dataclass +from enum import IntEnum + + +rows = 8 + +chess_board = [] + +for _ in range(rows): + cols = input() + chess_board.append(cols) + +black_score = 0 +white_score = 0 + + +class Score(IntEnum): + K = 0 + P = 1 + N = 3 + B = 3 + R = 5 + Q = 9 + + @classmethod + def get_score(cls, col): + col = col.upper() + + if col == "K": + return cls.K + elif col == "P": + return cls.P + elif col == "N": + return cls.N + elif col == "B": + return cls.B + elif col == "R": + return cls.R + else: + return cls.Q + + +for cols in chess_board: + for col in cols: + if col == ".": + continue + + is_black = col.islower() + + if is_black: + black_score += Score.get_score(col) + else: + white_score += Score.get_score(col) + +print(white_score - black_score) diff --git "a/Baekjoon Online Judge/\354\262\264\354\234\241\354\235\200_\354\210\230\355\225\231\352\263\274\353\252\251_\354\236\205\353\213\210\353\213\244.py" "b/Baekjoon Online Judge/\354\262\264\354\234\241\354\235\200_\354\210\230\355\225\231\352\263\274\353\252\251_\354\236\205\353\213\210\353\213\244.py" new file mode 100644 index 0000000..b28eea5 --- /dev/null +++ "b/Baekjoon Online Judge/\354\262\264\354\234\241\354\235\200_\354\210\230\355\225\231\352\263\274\353\252\251_\354\236\205\353\213\210\353\213\244.py" @@ -0,0 +1,4 @@ +h = int(input()) +w = int(input()) + +print(min(h, w) * 100 // 2) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\354\275\224\353\223\234\353\247\210\354\212\244\355\204\260_2023.py" "b/Baekjoon Online Judge/\354\275\224\353\223\234\353\247\210\354\212\244\355\204\260_2023.py" new file mode 100644 index 0000000..7e8817b --- /dev/null +++ "b/Baekjoon Online Judge/\354\275\224\353\223\234\353\247\210\354\212\244\355\204\260_2023.py" @@ -0,0 +1,10 @@ +def solution(input_word: str) -> str: + return { + "SONGDO": "HIGHSCHOOL", + "CODE": "MASTER", + "2023": "0611", + "ALGORITHM": "CONTEST", + }[input_word] + + +print(solution(input())) diff --git "a/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\352\260\200\354\247\200.py" "b/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\352\260\200\354\247\200.py" new file mode 100644 index 0000000..58d386a --- /dev/null +++ "b/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\352\260\200\354\247\200.py" @@ -0,0 +1,5 @@ +n = int(input()) +m = int(input()) +k = int(input()) + +print(int(m / n * k)) diff --git "a/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\354\236\221\354\235\200_\353\266\204\354\210\230.c" "b/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\354\236\221\354\235\200_\353\266\204\354\210\230.c" new file mode 100644 index 0000000..e69de29 diff --git "a/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\354\236\221\354\235\200_\353\266\204\354\210\230.py" "b/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\354\236\221\354\235\200_\353\266\204\354\210\230.py" new file mode 100644 index 0000000..7b2c7d7 --- /dev/null +++ "b/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\354\236\221\354\235\200_\353\266\204\354\210\230.py" @@ -0,0 +1,11 @@ +x, n = map(int, input().split()) + +result = 0 + +for _ in range(n): + if x % 2 == 0: + x = int(x / 2) ^ 6 + else: + x = int(2 * x) ^ 6 + +print(x) diff --git "a/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\355\225\231\352\265\220_\354\235\264\353\246\204.py" "b/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\355\225\231\352\265\220_\354\235\264\353\246\204.py" new file mode 100644 index 0000000..dfc3f82 --- /dev/null +++ "b/Baekjoon Online Judge/\355\212\271\353\263\204\355\225\234_\355\225\231\352\265\220_\354\235\264\353\246\204.py" @@ -0,0 +1,19 @@ +NLCS = "North London Collegiate School" +BHA = "Branksome Hall Asia" +KIS = "Korea International School" +SJA = "St. Johnsbury Academy" + + +def solution(input_word: str) -> str: + if input_word == "NLCS": + return NLCS + elif input_word == "BHA": + return BHA + elif input_word == "KIS": + return KIS + else: + return SJA + + +input_word = input() +print(solution(input_word)) diff --git "a/Baekjoon Online Judge/\355\214\251\355\206\240\353\246\254\354\226\274_3.py" "b/Baekjoon Online Judge/\355\214\251\355\206\240\353\246\254\354\226\274_3.py" new file mode 100644 index 0000000..e529bd9 --- /dev/null +++ "b/Baekjoon Online Judge/\355\214\251\355\206\240\353\246\254\354\226\274_3.py" @@ -0,0 +1,9 @@ +import math + + +def solution(n: int) -> int: + return math.factorial(n) + + +n = int(input()) +print(solution(n)) diff --git "a/Baekjoon Online Judge/\355\225\231\353\262\210\354\235\204_\354\260\276\354\225\204\354\244\230.py" "b/Baekjoon Online Judge/\355\225\231\353\262\210\354\235\204_\354\260\276\354\225\204\354\244\230.py" new file mode 100644 index 0000000..2893180 --- /dev/null +++ "b/Baekjoon Online Judge/\355\225\231\353\262\210\354\235\204_\354\260\276\354\225\204\354\244\230.py" @@ -0,0 +1,18 @@ +t = int(input()) +standard_score = list(map(int, input().split()))+ [0] * (5 - t) + +result = 0 +if standard_score[0] > standard_score[2]: + result += (standard_score[0] - standard_score[2]) * 508 +else: + result += (standard_score[2] - standard_score[0]) * 108 + +if standard_score[1] > standard_score[3]: + result += standard_score[1] - standard_score[3] * 212 +else: + result += abs(standard_score[1] - standard_score[3]) * 305 + +if standard_score[4] > 0: + result += standard_score[4] * 707 + +print(result * 4763) \ No newline at end of file diff --git "a/Baekjoon Online Judge/\355\225\231\354\213\235_\354\202\254\354\243\274\352\270\260.py" "b/Baekjoon Online Judge/\355\225\231\354\213\235_\354\202\254\354\243\274\352\270\260.py" new file mode 100644 index 0000000..7336daa --- /dev/null +++ "b/Baekjoon Online Judge/\355\225\231\354\213\235_\354\202\254\354\243\274\352\270\260.py" @@ -0,0 +1,6 @@ +n = int(input()) +menu_prices = [int(input()) for _ in range(n)] +m = int(input()) +corner_numbers = [int(input()) for _ in range(m)] + +print(sum(menu_prices[corner_number - 1] for corner_number in corner_numbers)) diff --git "a/Baekjoon Online Judge/\355\230\270\353\260\230\354\232\260\352\260\200_\355\225\231\352\265\220\354\227\220_\354\247\200\352\260\201\355\225\234_\354\235\264\354\234\240_1.py" "b/Baekjoon Online Judge/\355\230\270\353\260\230\354\232\260\352\260\200_\355\225\231\352\265\220\354\227\220_\354\247\200\352\260\201\355\225\234_\354\235\264\354\234\240_1.py" new file mode 100644 index 0000000..e03eecf --- /dev/null +++ "b/Baekjoon Online Judge/\355\230\270\353\260\230\354\232\260\352\260\200_\355\225\231\352\265\220\354\227\220_\354\247\200\352\260\201\355\225\234_\354\235\264\354\234\240_1.py" @@ -0,0 +1,9 @@ +str_, dex, int_, luk, n = map(int, input().split()) + +sum_of_all_stats = str_ + dex + int_ + luk +result = 4 * n - sum_of_all_stats + +if result <= 0: + print("0") +else: + print(result) diff --git "a/Baekjoon Online Judge/\355\231\200\354\247\235\355\231\200\354\247\235.py" "b/Baekjoon Online Judge/\355\231\200\354\247\235\355\231\200\354\247\235.py" new file mode 100644 index 0000000..1f8dff7 --- /dev/null +++ "b/Baekjoon Online Judge/\355\231\200\354\247\235\355\231\200\354\247\235.py" @@ -0,0 +1,17 @@ +from collections import Counter + + +_ = int(input()) +k = int(input()) + +result = Counter(num % 2 == 1 for num in map(int, str(k))) + +odd_count = result[True] +even_count = result[False] + +if even_count > odd_count: + print(0) +elif even_count < odd_count: + print(1) +else: + print(-1) diff --git a/kata_2025/project_euler/1.py b/kata_2025/project_euler/1.py new file mode 100644 index 0000000..a125171 --- /dev/null +++ b/kata_2025/project_euler/1.py @@ -0,0 +1,27 @@ +""" +If we list all the natural numbers below 10 + that are multiples of 3 or 5, + we get 3, 5, 6 and 9. + The sum of these multiples is 23. + +Find the sum of all the multiples of 3 or 5 below 1000. +- 3의 배수의 합 + 5의 배수의 합 - 15의 배수의 합 (중복 제거) +""" + + +def sum_multiples_of(target_number: int, divisor: int) -> int: + last = ((target_number - 1) // divisor) * divisor + count = last // divisor + return (divisor + last) * count // 2 + + +def sum_of_multiples(target_number: int, a: int, b: int) -> int: + return ( + sum_multiples_of(target_number, a) + + sum_multiples_of(target_number, b) # 3의 배수의 합 + - sum_multiples_of(target_number, a * b) # 5의 배수의 합 # 15의 배수의 합(중복 제거) + ) + + +if __name__ == "__main__": + print(sum_of_multiples(1000, 3, 5)) # 1000 미만의 3 또는 5의 배수의 합 diff --git a/kata_2025/project_euler/2.py b/kata_2025/project_euler/2.py new file mode 100644 index 0000000..55b462d --- /dev/null +++ b/kata_2025/project_euler/2.py @@ -0,0 +1,23 @@ +""" +Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: + +1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... + +By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. +""" + + +def fibonacci_even_sum(limit: int) -> int: + a, b = 1, 2 + total = 0 + + while a <= limit: + if a % 2 == 0: + total += a + a, b = b, a + b + + return total + + +if __name__ == "__main__": + print(fibonacci_even_sum(4_000_000)) diff --git a/python/oop/function_overload_sample.py b/python/oop/function_overload_sample.py new file mode 100644 index 0000000..d230437 --- /dev/null +++ b/python/oop/function_overload_sample.py @@ -0,0 +1,29 @@ +from typing import Union + +DATA_FORMAT_NORMAL = "normal" +DATA_FORMAT_NUMBER = "number" + + +class Cell: + def set_data_format(self, data_format: str): + ... + + def set_data(self, data: str): + ... + + +def write(cell: Cell, data: Union[str, int]): + if isinstance(data, str): + cell.set_data_format(DATA_FORMAT_NORMAL) + elif isinstance(data, int): + cell.set_data_format(DATA_FORMAT_NUMBER) + else: + raise TypeError(f"지원하지 않는 타입입니다: {type(data)}") + + cell.set_data(data) + + +# 사용 예시: +# cell = Cell() +# write(cell, "Hello") # 문자열 처리 +# write(cell, 42) # 숫자 처리 diff --git a/python/oop/intersection_type_test.py b/python/oop/intersection_type_test.py new file mode 100644 index 0000000..7dff7ca --- /dev/null +++ b/python/oop/intersection_type_test.py @@ -0,0 +1,8 @@ +def stringify(value: int | float) -> str: + return str(value) + + +if __name__ == "__main__": + print(stringify(1)) + print(stringify(1.0)) + print(stringify("1")) diff --git a/python/oop/location_sensitive_type_checking.py b/python/oop/location_sensitive_type_checking.py new file mode 100644 index 0000000..3b68b85 --- /dev/null +++ b/python/oop/location_sensitive_type_checking.py @@ -0,0 +1,31 @@ +# from typing import TypeGuard, Union + +# def is_string(x: object) -> TypeGuard[str]: +# return isinstance(x, str) + +# def process_value_custom_check(x: int | str) -> None: +# if isinstance(x, str): +# assert isinstance(x, str) # mypy에게 타입을 명시적으로 알림 +# print(x.upper()) # 오류 없음 +# else: +# print(x + 1) # 오류 없음 + +# process_value_custom_check("hello") +# process_value_custom_check(123) + + +from typing import Optional + +def is_none(x: Optional[str]) -> bool: + return x is None + +def handle_value(x: Optional[str]) -> None: + if is_none(x): + print("No value!") + return + # 여기서는 x가 None이 아님을 확정 + # 정적 분석기는 x를 'str'로 간주 + print(x.upper()) # OK + +handle_value("hello") +handle_value(None) diff --git a/python/oop/structure_typing_sample.py b/python/oop/structure_typing_sample.py new file mode 100644 index 0000000..9535efb --- /dev/null +++ b/python/oop/structure_typing_sample.py @@ -0,0 +1,27 @@ +from typing import Protocol, runtime_checkable + + +class PersonProtocol(Protocol): + name: str + age: int + + +class Person: + def __init__(self, name: str, age: int): + self.name = name + self.age = age + + +class Employee: + def __init__(self, name: str, height: int, department: str): + self.name = name + self.height = height + self.department = department + + +def greet(person: PersonProtocol): + print(f"Hello, {person.name}, age {person.height}") + + +employee = Employee("Alice", 30, "HR") +greet(employee) diff --git a/python/polymorphism/choose.py b/python/polymorphism/choose.py new file mode 100644 index 0000000..400ed8d --- /dev/null +++ b/python/polymorphism/choose.py @@ -0,0 +1,27 @@ +from typing import TypeVar, Generic, Type + +T = TypeVar('T') + +class Choose(Generic[T]): + @classmethod + def of(cls, type_: Type[T], v1: T, v2: T) -> T: + """타입을 명시적으로 지정할 수 있는 제네릭 메서드 + + Args: + type_ (Type[T]): 명시적 타입 + v1 (T): 첫 번째 값 + v2 (T): 두 번째 값 + + Returns: + T: 사용자 입력이 0이면 v1, 아니면 v2를 반환 + """ + print(f"Type: {type_.__name__}, Values: {v1}, {v2}") + result = int(input()) + return v1 if result == 0 else v2 + + +if __name__ == "__main__": + # 자바스러운 방식으로 사용 + print(Choose.of(int, 1, 0)) + print(Choose.of(str, "hello", "world")) + print(Choose.of(float, 1.5, 2.5)) \ No newline at end of file