結果

問題 No.2519 Coins in Array
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-10-27 23:02:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,437 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 108,364 KB
最終ジャッジ日時 2023-10-27 23:02:42
合計ジャッジ時間 16,572 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,212 KB
testcase_01 AC 40 ms
55,212 KB
testcase_02 AC 44 ms
61,248 KB
testcase_03 AC 43 ms
61,248 KB
testcase_04 AC 40 ms
54,984 KB
testcase_05 AC 41 ms
54,984 KB
testcase_06 AC 40 ms
55,212 KB
testcase_07 WA -
testcase_08 AC 41 ms
55,212 KB
testcase_09 WA -
testcase_10 AC 40 ms
55,212 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 41 ms
55,212 KB
testcase_15 AC 44 ms
61,248 KB
testcase_16 AC 41 ms
55,212 KB
testcase_17 AC 39 ms
55,212 KB
testcase_18 AC 43 ms
61,248 KB
testcase_19 AC 45 ms
61,248 KB
testcase_20 AC 40 ms
55,212 KB
testcase_21 WA -
testcase_22 AC 41 ms
55,212 KB
testcase_23 AC 1,705 ms
108,212 KB
testcase_24 RE -
testcase_25 AC 39 ms
55,216 KB
testcase_26 AC 40 ms
55,216 KB
testcase_27 AC 1,481 ms
108,220 KB
testcase_28 AC 1,491 ms
108,364 KB
testcase_29 AC 1,480 ms
108,364 KB
testcase_30 AC 1,100 ms
104,452 KB
testcase_31 AC 248 ms
80,920 KB
testcase_32 AC 111 ms
91,008 KB
testcase_33 WA -
testcase_34 AC 442 ms
86,360 KB
testcase_35 WA -
testcase_36 AC 369 ms
84,368 KB
testcase_37 AC 205 ms
79,836 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 178 ms
105,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n = int(input())
A = list(map(int,input().split()))

M = 2*10**5+5

count = [0]*M

for a in A:
    count[a] += 1


if count[1]:
    ans = 1
    print(ans)
    for i in range(n-1):
        print(1,2)
    
    exit()

ans = 10**18
if count[0]:
    ans = 0
    print(ans)
    for i in range(n-1):
        print(1,2)

    exit()

target = []
dic = {}
for ind,a in enumerate(A):
    now = a
    for i in range(2,int(a**0.5)+1):
        if now%i:
            continue
        if i in dic:
            target = [a,dic[i]]
        
        while now % i == 0:
            now //= i
        dic[i] = a

    if now != 1:
        dic[now] = a
    
if target:
    first = []
    for i,a in enumerate(A):
        if a in target:
            first.append(i+1)
            target.remove(a)
    
    print(0)
    print(*first)
    for i in range(n-2):
        print(1,2)
    exit()


even = []
odd = []
for i,a in enumerate(A):
    if a%2 == 0:
        even.append(i+1)
    else:
        odd.append(i+1)

assert len(even) < 2

if n == 2:
    ans = (A[0]-1)*(A[1]-1)
    print(ans)
    print(1,2)
    exit()


if even == []:
    if n > 4:
        print(0)
    else:
        ans = (A[0]-1)*(A[1]-1)

        ans = (ans-1)*(A[2]-1)
        print(ans)

    for i in range(n-1):
        print(1,2)


    exit()



else:
    ans = 0
    print(0)
    print(odd.pop(),odd.pop())
    print(n-1,even.pop())
    for i in range(n-3):
        print(1,2)
0