結果

問題 No.983 Convolution
ユーザー ganmodokixganmodokix
提出日時 2020-02-11 16:52:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 713 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 30,504 KB
最終ジャッジ日時 2024-04-08 15:37:51
合計ジャッジ時間 29,337 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,368 KB
testcase_01 AC 32 ms
10,368 KB
testcase_02 AC 34 ms
10,368 KB
testcase_03 AC 1,322 ms
22,952 KB
testcase_04 AC 1,063 ms
20,964 KB
testcase_05 AC 889 ms
18,900 KB
testcase_06 AC 1,529 ms
24,068 KB
testcase_07 AC 1,516 ms
24,536 KB
testcase_08 AC 260 ms
13,184 KB
testcase_09 AC 543 ms
15,100 KB
testcase_10 AC 166 ms
12,160 KB
testcase_11 AC 290 ms
13,944 KB
testcase_12 TLE -
testcase_13 AC 463 ms
15,188 KB
testcase_14 AC 590 ms
16,044 KB
testcase_15 AC 1,331 ms
22,984 KB
testcase_16 AC 948 ms
19,072 KB
testcase_17 AC 1,608 ms
24,220 KB
testcase_18 AC 235 ms
12,928 KB
testcase_19 AC 915 ms
19,728 KB
testcase_20 AC 1,990 ms
26,156 KB
testcase_21 AC 1,287 ms
23,444 KB
testcase_22 AC 289 ms
13,164 KB
testcase_23 AC 1,121 ms
20,652 KB
testcase_24 AC 243 ms
12,672 KB
testcase_25 AC 211 ms
12,288 KB
testcase_26 AC 718 ms
17,068 KB
testcase_27 AC 514 ms
15,232 KB
testcase_28 AC 906 ms
19,912 KB
testcase_29 AC 1,922 ms
30,504 KB
testcase_30 AC 940 ms
19,900 KB
testcase_31 AC 490 ms
15,636 KB
testcase_32 AC 1,032 ms
21,096 KB
testcase_33 AC 32 ms
10,368 KB
testcase_34 AC 32 ms
10,368 KB
testcase_35 AC 33 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import random
# import numpy as np

def gcd(x: int, y: int) -> int:
    if x < y: x, y = y, x
    while y > 0:
        x %= y
        x, y = y, x
    return x

# code here
n = int(input())
a = [*map(lambda x: int(x) if x != "-1" else 0, input().split())]

mask = 1
while mask < n:
    for i in range(n):
        if not i & mask and (i | mask) < n:
            a[i] += a[i | mask]
    mask <<= 1

for i in range(n):
    a[i] **= 2

mask = 1
while mask < n:
    for i in range(n):
        if not i & mask and (i | mask) < n:
            a[i] -= a[i | mask]
    mask <<= 1

ans = -1
for x in a:
    if x == 0: continue
    if ans == -1:
        ans = x
    else:
        ans = gcd(ans, abs(x))
print(ans)
0