結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,232 KB
testcase_01 AC 71 ms
71,276 KB
testcase_02 AC 69 ms
70,960 KB
testcase_03 AC 69 ms
71,212 KB
testcase_04 AC 67 ms
70,936 KB
testcase_05 WA -
testcase_06 AC 71 ms
70,976 KB
testcase_07 AC 70 ms
71,096 KB
testcase_08 AC 68 ms
71,136 KB
testcase_09 AC 70 ms
71,324 KB
testcase_10 AC 69 ms
71,096 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 69 ms
71,044 KB
testcase_15 AC 70 ms
70,916 KB
testcase_16 WA -
testcase_17 AC 71 ms
71,236 KB
testcase_18 AC 69 ms
70,932 KB
testcase_19 AC 69 ms
70,736 KB
testcase_20 AC 69 ms
70,868 KB
testcase_21 AC 70 ms
71,056 KB
testcase_22 AC 69 ms
71,236 KB
testcase_23 AC 192 ms
105,932 KB
testcase_24 AC 195 ms
105,736 KB
testcase_25 AC 71 ms
71,052 KB
testcase_26 AC 69 ms
71,048 KB
testcase_27 AC 194 ms
106,068 KB
testcase_28 AC 193 ms
106,052 KB
testcase_29 AC 196 ms
105,968 KB
testcase_30 AC 191 ms
104,252 KB
testcase_31 AC 107 ms
82,160 KB
testcase_32 AC 143 ms
98,164 KB
testcase_33 AC 167 ms
107,720 KB
testcase_34 AC 127 ms
90,380 KB
testcase_35 AC 159 ms
105,460 KB
testcase_36 AC 117 ms
87,228 KB
testcase_37 AC 104 ms
79,876 KB
testcase_38 AC 148 ms
100,660 KB
testcase_39 AC 121 ms
88,656 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 = [0] * 2
        lis2 = [0] * 2
        b = sorted(a)[:2]
        for i in range(2):
            for j, x in enumerate(a, 1):
                if(x != b[i]):
                    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