結果

問題 No.2519 Coins in Array
ユーザー MasKoaTSMasKoaTS
提出日時 2023-09-02 15:57:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 744 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 114,248 KB
最終ジャッジ日時 2023-09-19 13:50:58
合計ジャッジ時間 9,968 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,280 KB
testcase_01 AC 74 ms
71,304 KB
testcase_02 AC 74 ms
71,328 KB
testcase_03 AC 74 ms
71,388 KB
testcase_04 AC 73 ms
71,264 KB
testcase_05 AC 73 ms
71,388 KB
testcase_06 AC 74 ms
71,296 KB
testcase_07 AC 75 ms
71,200 KB
testcase_08 AC 75 ms
71,208 KB
testcase_09 AC 75 ms
71,196 KB
testcase_10 AC 75 ms
71,340 KB
testcase_11 AC 71 ms
71,368 KB
testcase_12 AC 74 ms
71,320 KB
testcase_13 AC 73 ms
71,304 KB
testcase_14 AC 73 ms
71,408 KB
testcase_15 AC 73 ms
71,348 KB
testcase_16 AC 74 ms
71,200 KB
testcase_17 AC 75 ms
71,384 KB
testcase_18 AC 74 ms
71,292 KB
testcase_19 AC 72 ms
71,372 KB
testcase_20 AC 74 ms
71,428 KB
testcase_21 AC 76 ms
71,140 KB
testcase_22 AC 71 ms
71,596 KB
testcase_23 AC 223 ms
106,288 KB
testcase_24 AC 207 ms
106,272 KB
testcase_25 AC 71 ms
71,212 KB
testcase_26 AC 76 ms
71,332 KB
testcase_27 AC 210 ms
106,320 KB
testcase_28 AC 211 ms
106,336 KB
testcase_29 AC 213 ms
106,324 KB
testcase_30 AC 203 ms
104,432 KB
testcase_31 AC 114 ms
82,596 KB
testcase_32 AC 153 ms
98,800 KB
testcase_33 AC 179 ms
108,228 KB
testcase_34 AC 134 ms
90,920 KB
testcase_35 AC 172 ms
105,728 KB
testcase_36 AC 125 ms
87,200 KB
testcase_37 AC 109 ms
80,048 KB
testcase_38 AC 159 ms
101,324 KB
testcase_39 AC 132 ms
88,948 KB
testcase_40 AC 210 ms
114,248 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):
    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), (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