/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 16ms 3.062 MiB
#2 Accepted 16ms 3.137 MiB
#3 Accepted 24ms 3.141 MiB
#4 Accepted 23ms 3.008 MiB
#5 Accepted 23ms 3.062 MiB
#6 Accepted 23ms 3.078 MiB

Code

s=input()
for i in range(int(input())):
    R_NEW=0
    X,Y=map(int,input().split())
    LHS,RHS = s.split('=')
    if 'y' in LHS:
        LHS = LHS.replace('y', '1')
        LHS_NEW=int(LHS)*Y
    else:
        LHS_NEW=int(LHS)
    if 'x' in RHS:
        L,R = RHS.split('x')
        if L=='':
            L_NEW=1*X
        elif L=='-':
            L_NEW=-1*X
        else:
            L_NEW = int(L) * X
        if R!='':
            if R[0]=="+":
                R=R[1:]
                R_NEW += int(R)
            elif R[0]=='-':
                R=R[1:]
                R_NEW += int(R)*-1
        else:
            R_NEW = 0
        RHS_NEW = L_NEW + R_NEW
    else:
        RHS_NEW=int(RHS)
    if LHS_NEW==RHS_NEW:
        print("YES")
    else:
        print("NO")









Information

Submit By
Type
Submission
Problem
P1015 Friend in need is a friend indeed
Language
Python 3 (Python 3.12.3)
Submit At
2024-01-09 14:22:22
Judged At
2024-11-11 03:43:36
Judged By
Score
100
Total Time
24ms
Peak Memory
3.141 MiB