結果

問題 No.2519 Coins in Array
ユーザー MasKoaTSMasKoaTS
提出日時 2023-09-19 20:23:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 109,124 KB
最終ジャッジ日時 2023-09-19 20:32:10
合計ジャッジ時間 9,368 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,572 KB
testcase_01 AC 72 ms
71,744 KB
testcase_02 AC 71 ms
71,672 KB
testcase_03 AC 70 ms
71,564 KB
testcase_04 AC 72 ms
71,444 KB
testcase_05 AC 72 ms
71,184 KB
testcase_06 AC 71 ms
71,812 KB
testcase_07 AC 71 ms
71,388 KB
testcase_08 AC 70 ms
71,452 KB
testcase_09 AC 72 ms
71,384 KB
testcase_10 AC 70 ms
71,252 KB
testcase_11 AC 72 ms
71,736 KB
testcase_12 AC 71 ms
71,516 KB
testcase_13 AC 72 ms
71,448 KB
testcase_14 AC 70 ms
71,812 KB
testcase_15 AC 69 ms
71,748 KB
testcase_16 AC 70 ms
71,748 KB
testcase_17 AC 70 ms
71,580 KB
testcase_18 AC 69 ms
71,728 KB
testcase_19 AC 71 ms
71,568 KB
testcase_20 AC 71 ms
71,264 KB
testcase_21 AC 71 ms
71,472 KB
testcase_22 AC 71 ms
71,544 KB
testcase_23 AC 191 ms
108,960 KB
testcase_24 AC 188 ms
108,488 KB
testcase_25 AC 72 ms
71,444 KB
testcase_26 AC 71 ms
71,444 KB
testcase_27 AC 191 ms
108,900 KB
testcase_28 AC 187 ms
109,124 KB
testcase_29 AC 192 ms
108,880 KB
testcase_30 AC 181 ms
105,204 KB
testcase_31 AC 108 ms
80,692 KB
testcase_32 AC 142 ms
92,176 KB
testcase_33 AC 159 ms
99,340 KB
testcase_34 AC 125 ms
86,836 KB
testcase_35 AC 155 ms
96,888 KB
testcase_36 AC 116 ms
84,344 KB
testcase_37 AC 102 ms
79,596 KB
testcase_38 AC 143 ms
94,000 KB
testcase_39 AC 118 ms
85,664 KB
testcase_40 AC 184 ms
107,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import gcd
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):
    ans = f(f(a[0], a[1]), a[2])
    ops = [(1, 2), (1, 2)]
    t = f(f(a[0], a[2]), a[1])
    if(t < ans):
        ans = t
        ops = [(1, 3), (1, 2)]
    t = f(f(a[1], a[2]), a[0])
    if(t < ans):
        ans = t
        ops = [(2, 3), (1, 2)]
else:
    ans = 0
    ops = [(1, 2) for _ in [0] * (n - 1)]

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