CSES - Datatähti 2023 loppu - Results
Submission details
Task:Pinta-ala
Sender:okkokko
Submission time:2023-01-21 13:57:50 +0200
Language:Python3 (PyPy3)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.08 sdetails
#2ACCEPTED0.08 sdetails
#3ACCEPTED0.08 sdetails

Code

import math
t = int(input())
def check(a:int,b:int):
# a = c*d
# b = (c+1)*(d+1) = c*d + c + d + 1
# c = a/d
# b = a + a/d + d + 1
# b = a*(1 + 1/d) + (d + 1)
# b = (a/d +1)*(d + 1)
# b = a + a/d + d + 1
# a/d + d = (b -1 -a)
# | * d
# d*d - (b -1 -a)*d + a= 0
# (-b+-sqrt(b²-4ac))/(2a)
return has_positive_solution(1,-b+1+a,a)
def has_positive_solution(a,b,c):
return b*b- 4*a*c>=0 and (-b +math.sqrt(b*b- 4*a*c))/(2*a)>0
for _ in range(t):
A,B = map(int,input().split())
print("YES" if check(A,B) else "NO")

Test details

Test 1

Verdict: ACCEPTED

input
1000
578049 731905
262997 434601
559974 650052
458543 101143
...

correct output
YES
YES
YES
NO
NO
...

user output
YES
YES
YES
NO
NO
...
Truncated

Test 2

Verdict: ACCEPTED

input
1000
10000 9500
10000 9501
10000 9502
10000 9503
...

correct output
NO
NO
NO
NO
NO
...

user output
NO
NO
NO
NO
NO
...
Truncated

Test 3

Verdict: ACCEPTED

input
961
1 1
1 2
1 3
1 4
...

correct output
NO
NO
NO
YES
YES
...

user output
NO
NO
NO
YES
YES
...
Truncated