Submission #22447816


Source Code Expand

import sys
from math import floor
import random

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(x):
    memo = {}
    
    x2 = x * x
    x3 = x * x * x

    def f(a, b, c):
        return a * x3 + b * x2 + c * x

    while True:
        a = random.randint(0, 1000)
        b = random.randint(0, 10000)
        c = random.randint(0, 100000)
        fx = f(a, b, c)
        d = floor(fx)
        key = int((2 * 10**10) * (fx - d))
        if key in memo:
            a1, b1, c1 = memo[key]
            if a == a1 and b == b1 and c == c1:
                continue
            a, b, c = a - a1, b - b1, c - c1
            fx = f(a, b, c)
            d = int(round(fx))
            if abs(fx - d) < 9e-11:
                return a, b, c, -d
        else:
            memo[key] = a, b, c

print(*main(float(read())))

Submission Info

Submission Time
Task I - Interesting Equation
User maspy
Language Python (3.8.2)
Score 100
Code Size 915 Byte
Status AC
Exec Time 697 ms
Memory 60944 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 25
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01.txt AC 22 ms 9428 KiB
02.txt AC 21 ms 9188 KiB
03.txt AC 70 ms 12368 KiB
04.txt AC 80 ms 13428 KiB
05.txt AC 179 ms 21356 KiB
06.txt AC 395 ms 36888 KiB
07.txt AC 81 ms 13532 KiB
08.txt AC 74 ms 12720 KiB
09.txt AC 630 ms 57272 KiB
10.txt AC 428 ms 38796 KiB
11.txt AC 653 ms 58380 KiB
12.txt AC 697 ms 60944 KiB
13.txt AC 558 ms 56340 KiB
14.txt AC 690 ms 60924 KiB
15.txt AC 511 ms 44440 KiB
16.txt AC 528 ms 45912 KiB
17.txt AC 597 ms 56252 KiB
18.txt AC 153 ms 20984 KiB
19.txt AC 217 ms 23828 KiB
20.txt AC 150 ms 18052 KiB
21.txt AC 587 ms 56268 KiB
22.txt AC 519 ms 44420 KiB
sample-01.txt AC 111 ms 15760 KiB
sample-02.txt AC 30 ms 10092 KiB
sample-03.txt AC 242 ms 25496 KiB