結果
| 問題 |
No.2806 Cornflake Man
|
| コンテスト | |
| ユーザー |
YuuuT
|
| 提出日時 | 2024-07-12 22:06:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,243 bytes |
| コンパイル時間 | 143 ms |
| コンパイル使用メモリ | 82,232 KB |
| 実行使用メモリ | 140,356 KB |
| 最終ジャッジ日時 | 2024-07-12 22:06:28 |
| 合計ジャッジ時間 | 5,085 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 10 TLE * 1 -- * 5 |
ソースコード
# oj t -c "python3 main.py"
import sys,math
from collections import defaultdict,deque
from itertools import combinations,permutations,accumulate,product
from bisect import bisect_left,bisect_right
from heapq import heappop,heappush,heapify
#from sortedcontainers import SortedList,SortedSet
def input():return sys.stdin.readline().rstrip()
def ii(): return int(input())
def ms(): return map(int, input().split())
def li(): return list(map(int,input().split()))
inf = pow(10,18)
mod = 998244353
#//////////////////////////////////
N,M = ms()
A = li()
A.sort()
AS = set(A)
ans = list()
ok = set()
ng = set()
def judge(a):
num = list()
for i in range(2,a+1):
if i*i>a: break
if a%i!=0: continue
num.append(i)
if a//i!=i:
num.append(a//i)
num.append(a)
num.sort()
for j in num:
if j in ng: continue
tmp = j
while tmp<=A[-1]:
if tmp not in AS:
ng.add(j)
break
tmp += j
if j in ng: continue
else:
tmp = j
while tmp<=A[-1]:
ok.add(tmp)
tmp += j
return j
return -1
for i in range(1,N):
if A[i] in ok: continue
res = judge(A[i])
if res==-1:
print(-1)
exit()
ans.append(res)
ans.sort()
print(len(ans))
print(*ans)
YuuuT