QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#339125#5542. Doubled GCDAllSolvedin1557#Compile Error//C++20746b2024-02-26 19:36:562024-02-26 19:36:58

Judging History

你现在查看的是最新测评结果

  • [2024-02-26 19:36:58]
  • 评测
  • [2024-02-26 19:36:56]
  • 提交

answer

import sys
import heapq
def gcd(a,b):
    if b == 0 :
        return a
    return gcd(b, a % b)
n = int(sys.stdin.readline())
L = list(map(int,sys.stdin.readline().split()))
X2 = []
g = 0 
for i in range(n):
    g = gcd(g, L[i])

for i in range(n):
    L[i] = L[i] // g
for i in range(n):
    a = L[i]
    zz = 0 
    while (a % 2 == 0):
        a = a // 2
        zz += 1
    X2.append(zz)
X2.sort()
power = [0 for i in range(100)]
for x in X2:
    power[x] += 1
aa = 0
for i in range(99):
    if power[i] != 0:
        if power[i] == 1 and power[i + 1] == 0:
            aa = i
            break
    power[i + 1] += power[i] // 2
    power[i] = 0
if sum(power[aa + 1:]) >= 1:
    aa += 1
print(g * (1 << aa))

Details

answer.code:1:1: error: ‘import’ does not name a type
    1 | import sys
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’, which is not yet enabled with ‘-std=c++20’