# 素数之积

```n = int(input())

#### 打表 ####

import bisect

primes = [...]  #表略

sqrt = n ** 0.5

for p in primes:
if p > sqrt:
print(-1, -1)
break
if n % p == 0:
div = n // p
if div <= primes[-1]:
if primes[bisect.bisect_left(primes, div)] == div:
print(p, div)
break
else:
is_prime = True
sqrt2 = div ** 0.5
for p2 in primes:
if p2 > sqrt2:
break
if div % p2 == 0:
is_prime = False
break
if is_prime:
print(p, div)
break
else:
print(-1, -1)

#### 枚举 ####

def is_prime(n):
if n == 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True

for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
if is_prime(i) and is_prime(n // i):
print(i, n // i)
break
else:
print(-1, -1)```

# 工厂流水线

```import heapq

m, n = map(int, input().split())
t = list(map(int, input().split()))[:n]

t.sort()

h = t[:m]

heapq.heapify(h)

for i in range(m, n):
heapq.heapreplace(h, h[0] + t[i])

print(max(h))```

# 完全波形信号

```import re

s = '0' + input() + '0'

waves = re.sub(r'0{2,}', '0|0', s).split('|')[1:-1]

ans = ''

for w in waves:
if all(w[i] != w[i + 1] for i in range(len(w) - 1)):
ans = max(ans, w, key=len)

print(ans or -1)```
#华为笔试##外企德科人力资源服务##华为OD#

1

07-12 19:53

07-12 01:28

5 27 评论