結果

問題 No.2519 Coins in Array
ユーザー MasKoaTSMasKoaTS
提出日時 2023-09-03 17:50:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 933 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 108,332 KB
最終ジャッジ日時 2023-09-05 16:53:22
合計ジャッジ時間 8,331 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,244 KB
testcase_01 AC 68 ms
71,284 KB
testcase_02 AC 69 ms
71,252 KB
testcase_03 AC 69 ms
71,680 KB
testcase_04 AC 69 ms
71,380 KB
testcase_05 AC 69 ms
71,408 KB
testcase_06 AC 68 ms
71,352 KB
testcase_07 AC 69 ms
71,560 KB
testcase_08 AC 68 ms
71,100 KB
testcase_09 AC 68 ms
71,348 KB
testcase_10 AC 70 ms
71,664 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 69 ms
71,412 KB
testcase_15 AC 75 ms
71,692 KB
testcase_16 WA -
testcase_17 AC 69 ms
71,532 KB
testcase_18 AC 68 ms
71,472 KB
testcase_19 AC 71 ms
71,036 KB
testcase_20 AC 69 ms
71,344 KB
testcase_21 AC 70 ms
71,376 KB
testcase_22 AC 71 ms
71,264 KB
testcase_23 AC 200 ms
106,232 KB
testcase_24 AC 194 ms
106,352 KB
testcase_25 AC 68 ms
71,312 KB
testcase_26 AC 67 ms
71,444 KB
testcase_27 AC 189 ms
106,452 KB
testcase_28 AC 195 ms
106,556 KB
testcase_29 AC 192 ms
106,508 KB
testcase_30 AC 184 ms
104,632 KB
testcase_31 AC 109 ms
82,452 KB
testcase_32 AC 142 ms
98,664 KB
testcase_33 AC 164 ms
108,332 KB
testcase_34 AC 125 ms
91,048 KB
testcase_35 AC 157 ms
105,772 KB
testcase_36 AC 117 ms
87,460 KB
testcase_37 AC 103 ms
80,260 KB
testcase_38 AC 151 ms
101,140 KB
testcase_39 AC 123 ms
89,144 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:
    print(x, y)
0