/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 10ms 2.91 MiB
#2 Accepted 9ms 2.707 MiB
#3 Accepted 10ms 2.777 MiB
#4 Accepted 12ms 2.777 MiB
#5 Accepted 14ms 2.668 MiB
#6 Accepted 13ms 2.68 MiB
#7 Accepted 13ms 2.684 MiB
#8 Accepted 19ms 2.738 MiB
#9 Accepted 19ms 2.777 MiB
#10 Accepted 19ms 2.777 MiB
#11 Accepted 14ms 2.742 MiB
#12 Accepted 13ms 2.793 MiB

Code

import math as m
t=int(input())
for _ in range(t):
    a,b,c,x = map(int,input().split())
    lcmm = m.lcm(a,b)
    lcmm = m.lcm(lcmm,c)
    gcm = (m.ceil(x/lcmm)-1)*lcmm
    if(gcm):
        print(gcm)
    else:
        print(-1)

Information

Submit By
Type
Submission
Problem
P1025 GCM
Language
Python 3 (Python 3.12.3)
Submit At
2024-01-10 09:43:53
Judged At
2024-01-21 15:51:45
Judged By
Score
100
Total Time
19ms
Peak Memory
2.91 MiB