/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 9ms 2.652 MiB
#2 Accepted 9ms 2.777 MiB
#3 Accepted 12ms 2.777 MiB
#4 Accepted 12ms 2.664 MiB
#5 Accepted 13ms 2.785 MiB
#6 Accepted 13ms 2.777 MiB
#7 Accepted 13ms 2.727 MiB
#8 Accepted 11ms 2.777 MiB
#9 Accepted 14ms 2.781 MiB
#10 Accepted 14ms 2.711 MiB
#11 Accepted 13ms 2.785 MiB

Code

def min_operations_to_zero(A, B):
    count = 0
    while A > 0 and B > 0:
        count += A // B
        A, B = B, A % B
    return count

def main():
    T = int(input())
    for _ in range(T):
        A, B = map(int, input().split())
        result = min_operations_to_zero(A, B)
        print(result)

if __name__ == "__main__":
    main()

Information

Submit By
Type
Submission
Problem
P1029 Make it zero
Contest
Brain booster #2
Language
Python 3 (Python 3.12.3)
Submit At
2024-03-06 16:47:18
Judged At
2024-03-06 16:47:18
Judged By
Score
100
Total Time
14ms
Peak Memory
2.785 MiB