/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 15ms 2.891 MiB
#2 Accepted 101ms 3.191 MiB
#3 Accepted 103ms 3.195 MiB
#4 Accepted 104ms 3.195 MiB
#5 Accepted 96ms 3.16 MiB
#6 Accepted 89ms 3.16 MiB
#7 Accepted 89ms 3.16 MiB
#8 Accepted 95ms 3.16 MiB
#9 Accepted 102ms 3.188 MiB
#10 Accepted 99ms 3.156 MiB

Code

import math

t = int(input())
for x in range(t):
    arr = []
    a,b,c = map(int,input().split())
    arr.extend((a,b,c))

    
    diff = []
    diff.append(abs(arr[0] - arr[1]))
    diff.append(abs(arr[1] - arr[2]))
    diff.append(abs(arr[2] - arr[0]))
    
    cut = 0
    for i in range(3):
        cut = math.gcd(cut, diff[i])
    if cut == 0:
        print(0)
    else:
        arr.sort()

        ans = 0
        ans += (arr[1] - arr[0]) // cut
        ans += (arr[2] - arr[1]) // cut
        print(ans)


Information

Submit By
Type
Submission
Problem
P1061 Bring equality
Contest
Brain Booster #4
Language
Python 3 (Python 3.12.3)
Submit At
2024-07-14 17:58:06
Judged At
2024-11-11 03:22:32
Judged By
Score
100
Total Time
104ms
Peak Memory
3.195 MiB