QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706155#8067. Scientific Gradingjerry2423WA 15ms10840kbPython31.7kb2024-11-03 07:50:572024-11-03 07:50:59

Judging History

This is the latest submission verdict.

  • [2024-11-03 07:50:59]
  • Judged
  • Verdict: WA
  • Time: 15ms
  • Memory: 10840kb
  • [2024-11-03 07:50:57]
  • Submitted

answer

import math

billion = 1_000_000_000

def add(xs, xe, ys, ye):
    # i = 0 if xe >= ye else 1
    # zs = [xs, ys][i]
    # ze = [xe, ye][i]
    zs = xs
    ze = xe
    if abs(xe - ye) <= 9:
        # zs += [xs, ys][not i] // (10 ** abs(xe - ye))
        zs += ys // (10 ** abs(xe - ye))
    return zs, ze

def sub(xs, xe, ys, ye, swapped):
    # i = 0 if xe >= ye else 1
    # zs = [xs, ys][i]
    # ze = [xe, ye][i]
    zs = xs
    ze = xe
    if abs(xe - ye) <= 9:
        # zs -= [xs, ys][not i] // (10 ** abs(xe - ye))
        zs -= ys // (10 ** abs(xe - ye))
    return zs * (-1 if swapped else 1), ze

def mul(xs, xe, ys, ye):
    correction = math.floor(math.log((xs // billion) * (ys // billion), 10))
    zs = round(xs * ys / billion / (10 ** correction))
    ze = xe + ye + correction
    return zs, ze

def div(xs, xe, ys, ye, swapped):
    if swapped:
        xs, xe, ys, ye = ys, ye, xs, xe
    correction = math.floor(math.log((xs // billion) / (ys // billion), 10))
    # print(correction)
    zs = round(xs / ys * billion * (10 ** -correction))
    ze = xe - ye + correction
    return zs, ze

def process(string):
    s, e = string.split("e")
    s = int(float(s) * billion)
    e = int(e)
    return s, e

xs, xe = process(input().strip())
ys, ye = process(input().strip())

# print(xs, xe)
# print(ys, ye)

swapped = False
if xs < ys:
    swapped = True
    xs, xe, ys, ye = ys, ye, xs, xe

x = (xs, xe)
y = (ys, ye)
ans = [add(*x, *y), sub(*x, *y, swapped), mul(*x, *y), div(*x, *y, swapped)]

for zts, zte in ans:
    zs, ze = process(input().strip())
    # print(zts, zte, zs, ze)
    if zts == zs and zte == ze:
        print("Correct")
    else:
        print("Incorrect")
    #print(zs, ze)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 10788kb

input:

+2.000000000e+1
+3.000000000e+2
+3.200000000e+2
-2.800000000e+2
+6.000000000e+3
+6.666666667e-2

output:

Correct
Correct
Correct
Correct

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 15ms
memory: 10776kb

input:

+1.000000000e-1
+1.000000000e-1
+2.000000003e-1
+1.000000000e-18
+1.000000002e-2
+1.000000001e+0

output:

Incorrect
Incorrect
Incorrect
Incorrect

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 15ms
memory: 10840kb

input:

+9.999999999e+400000000
+1.000000000e-400000009
+9.999999999e+400000000
+9.999999999e+400000000
+9.999999999e-9
+9.999999999e+800000009

output:

Correct
Correct
Correct
Correct

result:

ok 4 lines

Test #4:

score: -100
Wrong Answer
time: 7ms
memory: 10652kb

input:

+9.999999999e+999999996
+1.000000000e-4
+9.999999999e+999999996
+9.999999999e+999999996
+9.999999999e+999999992
+9.999999999e+1000000000

output:

Correct
Correct
Correct
Correct

result:

wrong answer 1st lines differ - expected: 'Incorrect', found: 'Correct'