結果

問題 No.691 E869120 and Constructing Array 5
ユーザー maspy
提出日時 2020-05-03 01:22:23
言語 Python3
(3.8.2 + numpy 1.14.5 + scipy 1.1.0)
結果
AC  
実行時間 39 ms / 1,000 ms
コード長 1,763 Byte
コンパイル時間 45 ms
使用メモリ 5,820 KB
最終ジャッジ日時 2020-05-03 01:22:27

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 37 ms
5,820 KB
testcase_01 AC 38 ms
5,816 KB
testcase_02 AC 39 ms
5,820 KB
testcase_03 AC 38 ms
5,812 KB
testcase_04 AC 39 ms
5,816 KB
testcase_05 AC 38 ms
5,816 KB
testcase_06 AC 38 ms
5,816 KB
testcase_07 AC 38 ms
5,816 KB
testcase_08 AC 39 ms
5,816 KB
testcase_09 AC 38 ms
5,816 KB
testcase_10 AC 38 ms
5,812 KB
testcase_11 AC 39 ms
5,816 KB
testcase_12 AC 38 ms
5,816 KB
testcase_13 AC 39 ms
5,816 KB
testcase_14 AC 38 ms
5,812 KB
testcase_15 AC 39 ms
5,816 KB
testcase_16 AC 38 ms
5,812 KB
testcase_17 AC 39 ms
5,820 KB
testcase_18 AC 39 ms
5,816 KB
testcase_19 AC 39 ms
5,812 KB
testcase_20 AC 39 ms
5,816 KB
testcase_21 AC 38 ms
5,820 KB
testcase_22 AC 39 ms
5,812 KB
testcase_23 AC 39 ms
5,816 KB
testcase_24 AC 38 ms
5,816 KB
testcase_25 AC 38 ms
5,816 KB
testcase_26 AC 38 ms
5,812 KB
testcase_27 AC 16 ms
5,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #
import sys

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

""" 手元計算で使用したもの
import numpy as np
def find_approx_1(target, U=200, items=1):
    x = np.sqrt(np.arange(U, dtype=np.float64))
    value = x
    for _ in range(items-1):
        value = np.add.outer(value, x)
    value %= 1
    n = np.argmin(np.abs(value - target))
    n = np.unravel_index(n, value.shape)
    return n, sum(x**.5 for x in n)
def find_approx_2(target, U=200, items=2):
    x = np.sqrt(np.arange(U, dtype=np.float64))
    value = x
    for _ in range(items-1):
        value = np.add.outer(value, x)
    value %= 1
    shape = value.shape
    value = value.ravel()
    I = value.argsort()
    value1 = value[I]
    x = value1
    y = (value1 - target) % 1
    i = np.maximum(0, np.searchsorted(x, 1 - y) - 1)
    add = x[i] + y
    m = np.argmin(np.abs(1 - add))
    n = i[m]
    m, n = I[m], I[n]
    x = value[m] + value[n]
    m = np.unravel_index(m, shape)
    n = np.unravel_index(n, shape)
    n = n + m
    x = sum(x ** .5 for x in n)
    return n, x
"""

use = [None] * 11
use[0] = (1,)
use[1] = (26,)
use[2] = (59, 152)
use[3] = (29,58)
use[4] = (201, 283)
use[5] = (457, 763)
use[6] = (79, 478, 495)
use[7] = (385, 444, 454)
use[8] = (200, 77, 130, 59)
use[9] = (454, 21, 212, 308)
use[10] = (83, 71, 131, 123, 59, 68)

vals = [sum(x**.5 for x in nums) for nums in use]

def solve(x):
    A = []
    for nums, val in zip(use[1:], vals[1:]):
        coef = int((x % 1) // (val % 1))
        x -= coef * val
        for n in nums:
            A.append(coef * coef * n)
    A.append(int(x) ** 2)
    return A

Q = int(readline())
for x in map(float, read().split()):
    A = solve(x)
    print(30, *A)
0