結果
問題 | No.691 E869120 and Constructing Array 5 |
ユーザー |
![]() |
提出日時 | 2020-05-03 01:22:23 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 57 ms / 1,000 ms |
コード長 | 1,763 bytes |
コンパイル時間 | 86 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-01-02 09:20:41 |
合計ジャッジ時間 | 3,995 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlines""" 手元計算で使用したものimport numpy as npdef find_approx_1(target, U=200, items=1):x = np.sqrt(np.arange(U, dtype=np.float64))value = xfor _ in range(items-1):value = np.add.outer(value, x)value %= 1n = 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 = xfor _ in range(items-1):value = np.add.outer(value, x)value %= 1shape = value.shapevalue = value.ravel()I = value.argsort()value1 = value[I]x = value1y = (value1 - target) % 1i = np.maximum(0, np.searchsorted(x, 1 - y) - 1)add = x[i] + ym = 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 + mx = sum(x ** .5 for x in n)return n, x"""use = [None] * 11use[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 * valfor n in nums:A.append(coef * coef * n)A.append(int(x) ** 2)return AQ = int(readline())for x in map(float, read().split()):A = solve(x)print(30, *A)