/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 15ms 3.059 MiB
#2 Accepted 15ms 3.062 MiB
#3 Accepted 21ms 3.094 MiB
#4 Accepted 21ms 3.078 MiB
#5 Accepted 20ms 3.129 MiB
#6 Accepted 20ms 2.902 MiB

Code

#y=0x+c
s = input()
n = len(s)
indx = 2
digit = 0
m = 0
c = 0
neg_m = False
neg_c = False

if s[2] == '-':
    neg_m = True
    indx += 1
if s[indx] == 'x':
    m = 1
    
else:
    #while s[indx] != 'x':
    digit = int(s[indx:s.index('x')])
    m *= 10
    m += digit
    #indx += 1
    indx = s.index('x')

if (neg_m):
    m *= (-1)

indx += 1

if indx<n:
    if s[indx]== '-':
        neg_c = True
        indx += 1
    else:
        indx += 1
#while indx < n:
if indx<n:
    digit = int(s[indx:n])
    c *= 10
    c += digit

if neg_c:
    c *= (-1)

#print(m)
#print(c)
#print(n)
for _ in range(int(input())):
    x, y = map(int, input().split())
    if y == (m * x + c):
        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-07 19:10:58
Judged At
2024-11-11 03:43:43
Judged By
Score
100
Total Time
21ms
Peak Memory
3.129 MiB