/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 15ms 3.062 MiB
#2 Wrong Answer 15ms 2.898 MiB

Code

def min_operations_to_zero(A, B):
    # Initialize the count of operations
    count = 0
    
    # Continue the operation until either A or B becomes zero
    while A > 0 and B > 0:
        # Update the maximum of A and B
        max_val = max(A, B)
        min_val = min(A, B)
        
        # Update the value of max(A, B)
        A = abs(max_val - min_val)
        B = min_val
        
        # Increment the count of operations
        count += 1
    
    # Add the remaining operations if one of them is not zero
    count += max(A, B)
    
    return count

# Number of test cases
T = int(input())

for _ in range(T):
    # Input for each test case
    A, B = map(int, input().split())
    
    # Find and print the minimum number of operations
    result = min_operations_to_zero(A, B)
    print(result)

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:18:58
Judged At
2024-11-11 03:41:22
Judged By
Score
0
Total Time
15ms
Peak Memory
3.062 MiB