結果
問題 | No.691 E869120 and Constructing Array 5 |
ユーザー | maspy |
提出日時 | 2020-05-03 01:22:23 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 60 ms / 1,000 ms |
コード長 | 1,763 bytes |
コンパイル時間 | 120 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-06-10 16:36:32 |
合計ジャッジ時間 | 3,853 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
10,880 KB |
testcase_01 | AC | 56 ms
11,008 KB |
testcase_02 | AC | 56 ms
10,752 KB |
testcase_03 | AC | 54 ms
10,752 KB |
testcase_04 | AC | 55 ms
10,880 KB |
testcase_05 | AC | 55 ms
10,752 KB |
testcase_06 | AC | 60 ms
10,880 KB |
testcase_07 | AC | 55 ms
10,880 KB |
testcase_08 | AC | 54 ms
11,008 KB |
testcase_09 | AC | 55 ms
10,880 KB |
testcase_10 | AC | 56 ms
11,008 KB |
testcase_11 | AC | 55 ms
10,880 KB |
testcase_12 | AC | 56 ms
10,880 KB |
testcase_13 | AC | 54 ms
11,008 KB |
testcase_14 | AC | 52 ms
10,880 KB |
testcase_15 | AC | 59 ms
11,136 KB |
testcase_16 | AC | 56 ms
11,008 KB |
testcase_17 | AC | 53 ms
10,880 KB |
testcase_18 | AC | 54 ms
10,880 KB |
testcase_19 | AC | 54 ms
10,880 KB |
testcase_20 | AC | 54 ms
10,880 KB |
testcase_21 | AC | 54 ms
10,880 KB |
testcase_22 | AC | 53 ms
11,008 KB |
testcase_23 | AC | 52 ms
10,880 KB |
testcase_24 | AC | 55 ms
10,880 KB |
testcase_25 | AC | 54 ms
10,880 KB |
testcase_26 | AC | 54 ms
10,880 KB |
testcase_27 | AC | 28 ms
10,624 KB |
ソースコード
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)