관리 메뉴

솜씨좋은장씨

[BaekJoon] 5344번 : GCD (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 5344번 : GCD (Python)

솜씨좋은장씨 2023. 1. 7. 02:06
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 GCD입니다.

 

5344번: GCD

The first line of input will be a positive integer, n, indicating the number of problem sets. Each problem set consist of two positive integers, separated by one or more spaces. There are no blank lines in the input.

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

def GCD(a, b):
    mod = a%b
    while mod > 0:
        a = b
        b = mod
        mod = a%b
    return b


if __name__ == "__main__":
    for _ in range(int(input())):
        a, b = map(int, input().split())
        print(GCD(a=a, b=b))

 

 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

 

Comments