結果

問題 No.983 Convolution
ユーザー vwxyzvwxyz
提出日時 2021-09-15 13:32:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 834 ms / 2,000 ms
コード長 1,075 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 182,144 KB
最終ジャッジ日時 2023-09-10 22:59:34
合計ジャッジ時間 19,815 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
91,552 KB
testcase_01 AC 253 ms
91,600 KB
testcase_02 AC 250 ms
91,308 KB
testcase_03 AC 698 ms
144,108 KB
testcase_04 AC 569 ms
132,712 KB
testcase_05 AC 523 ms
123,456 KB
testcase_06 AC 712 ms
152,328 KB
testcase_07 AC 704 ms
156,328 KB
testcase_08 AC 350 ms
101,252 KB
testcase_09 AC 393 ms
106,584 KB
testcase_10 AC 320 ms
98,124 KB
testcase_11 AC 355 ms
102,120 KB
testcase_12 AC 834 ms
175,656 KB
testcase_13 AC 385 ms
106,044 KB
testcase_14 AC 433 ms
112,832 KB
testcase_15 AC 647 ms
144,292 KB
testcase_16 AC 531 ms
125,156 KB
testcase_17 AC 742 ms
160,280 KB
testcase_18 AC 337 ms
100,688 KB
testcase_19 AC 515 ms
123,468 KB
testcase_20 AC 823 ms
182,144 KB
testcase_21 AC 634 ms
144,452 KB
testcase_22 AC 349 ms
101,800 KB
testcase_23 AC 331 ms
111,616 KB
testcase_24 AC 281 ms
97,008 KB
testcase_25 AC 279 ms
96,136 KB
testcase_26 AC 300 ms
104,844 KB
testcase_27 AC 294 ms
102,392 KB
testcase_28 AC 525 ms
125,036 KB
testcase_29 AC 826 ms
180,080 KB
testcase_30 AC 519 ms
124,620 KB
testcase_31 AC 401 ms
109,440 KB
testcase_32 AC 543 ms
128,280 KB
testcase_33 AC 248 ms
91,736 KB
testcase_34 AC 250 ms
91,616 KB
testcase_35 AC 250 ms
91,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import functools
import heapq
import itertools
import math
import random
import sys
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import degrees, gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

N=int(readline())
A=list(map(int,readline().split()))
for i in range(N):
    if A[i]==-1:
        A[i]=0
for bit in range(30):
    for i in range(N-1,-1,-1):
        if i>>bit&1:
            A[i^1<<bit]+=A[i]
for i in range(N):
    A[i]**=2
for bit in range(30):
    for i in range(N):
        if i>>bit&1:
            A[i^1<<bit]-=A[i]
g=0
for a in A:
    g=GCD(g,a)
if g==0:
    g=-1
print(g)
0