結果

問題 No.2519 Coins in Array
ユーザー MasKoaTSMasKoaTS
提出日時 2023-09-03 17:51:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 968 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 107,620 KB
最終ジャッジ日時 2023-09-05 16:53:24
合計ジャッジ時間 9,031 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,796 KB
testcase_01 AC 72 ms
71,128 KB
testcase_02 AC 75 ms
71,176 KB
testcase_03 AC 75 ms
70,876 KB
testcase_04 AC 74 ms
71,264 KB
testcase_05 AC 74 ms
71,324 KB
testcase_06 AC 74 ms
71,232 KB
testcase_07 AC 75 ms
71,140 KB
testcase_08 AC 74 ms
71,252 KB
testcase_09 AC 74 ms
71,096 KB
testcase_10 AC 76 ms
71,236 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 74 ms
71,368 KB
testcase_15 AC 76 ms
71,052 KB
testcase_16 WA -
testcase_17 AC 74 ms
71,092 KB
testcase_18 AC 74 ms
71,136 KB
testcase_19 AC 76 ms
71,168 KB
testcase_20 AC 73 ms
71,172 KB
testcase_21 AC 73 ms
70,916 KB
testcase_22 AC 75 ms
70,800 KB
testcase_23 AC 207 ms
105,860 KB
testcase_24 AC 208 ms
105,612 KB
testcase_25 AC 73 ms
70,820 KB
testcase_26 AC 73 ms
71,272 KB
testcase_27 AC 207 ms
105,872 KB
testcase_28 AC 206 ms
105,856 KB
testcase_29 AC 216 ms
105,976 KB
testcase_30 AC 200 ms
104,432 KB
testcase_31 AC 115 ms
82,112 KB
testcase_32 AC 152 ms
98,356 KB
testcase_33 AC 177 ms
107,620 KB
testcase_34 AC 133 ms
90,556 KB
testcase_35 AC 167 ms
105,380 KB
testcase_36 AC 124 ms
87,080 KB
testcase_37 AC 106 ms
79,668 KB
testcase_38 AC 157 ms
100,976 KB
testcase_39 AC 130 ms
88,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import gcd
from itertools import permutations
input = sys.stdin.readline

def f(x, y):
    if(gcd(x, y) == 1):
        return (x - 1) * (y - 1)
    return 0


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

ans = 10 ** 18
ops = []
if(n == 2):
    ans = f(a[0], a[1])
    ops = [(1, 2)]
elif(n == 3):
    while(len(a) > 1):
        lis1 = [-1] * 2
        lis2 = [0] * 2
        b = sorted(a)[:2]
        for i in range(2):
            for j, x in enumerate(a, 1):
                if(x != b[i] or j == lis1[0]):
                    continue
                lis1[i] = j
                lis2[i] = x
                break
        for x in lis2:
            a.remove(x)
        a.append(f(*lis2))
        ops.append(tuple(lis1))
    ans = a[0]
else:
    ans = 0
    ops = [(1, 2), (1, 2), (n - 3, n - 2)]
    for i in range(n - 3, 1, -1):
        ops.append((1, i))

print(ans)
for x, y in ops:
    if(x > y):
        x, y = y, x
    print(x, y)
0