結果

問題 No.983 Convolution
ユーザー ganmodokixganmodokix
提出日時 2020-02-11 16:53:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 156,024 KB
最終ジャッジ日時 2024-04-08 15:38:28
合計ジャッジ時間 10,210 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,228 KB
testcase_01 AC 43 ms
54,228 KB
testcase_02 AC 41 ms
54,228 KB
testcase_03 AC 400 ms
121,160 KB
testcase_04 AC 320 ms
106,824 KB
testcase_05 AC 294 ms
102,328 KB
testcase_06 AC 457 ms
131,660 KB
testcase_07 AC 436 ms
127,920 KB
testcase_08 AC 133 ms
81,728 KB
testcase_09 AC 169 ms
86,388 KB
testcase_10 AC 104 ms
78,700 KB
testcase_11 AC 135 ms
81,840 KB
testcase_12 AC 553 ms
150,592 KB
testcase_13 AC 178 ms
86,852 KB
testcase_14 AC 211 ms
90,560 KB
testcase_15 AC 403 ms
121,200 KB
testcase_16 AC 298 ms
103,044 KB
testcase_17 AC 468 ms
135,080 KB
testcase_18 AC 122 ms
80,492 KB
testcase_19 AC 290 ms
101,704 KB
testcase_20 AC 550 ms
149,636 KB
testcase_21 AC 390 ms
120,552 KB
testcase_22 AC 136 ms
81,620 KB
testcase_23 AC 98 ms
90,128 KB
testcase_24 AC 65 ms
72,948 KB
testcase_25 AC 63 ms
72,132 KB
testcase_26 AC 83 ms
82,928 KB
testcase_27 AC 77 ms
78,324 KB
testcase_28 AC 302 ms
102,864 KB
testcase_29 AC 549 ms
156,024 KB
testcase_30 AC 304 ms
102,740 KB
testcase_31 AC 187 ms
88,120 KB
testcase_32 AC 316 ms
106,392 KB
testcase_33 AC 41 ms
54,228 KB
testcase_34 AC 41 ms
54,228 KB
testcase_35 AC 41 ms
54,228 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