結果

問題 No.2519 Coins in Array
ユーザー MasKoaTSMasKoaTS
提出日時 2023-09-03 12:41:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 859 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 108,472 KB
最終ジャッジ日時 2023-09-05 16:53:05
合計ジャッジ時間 10,578 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
72,076 KB
testcase_01 AC 84 ms
72,460 KB
testcase_02 AC 85 ms
71,960 KB
testcase_03 AC 86 ms
72,196 KB
testcase_04 AC 86 ms
72,152 KB
testcase_05 AC 84 ms
72,076 KB
testcase_06 AC 86 ms
72,156 KB
testcase_07 AC 85 ms
72,332 KB
testcase_08 AC 85 ms
72,436 KB
testcase_09 AC 85 ms
72,152 KB
testcase_10 AC 86 ms
72,628 KB
testcase_11 AC 85 ms
72,436 KB
testcase_12 AC 85 ms
72,156 KB
testcase_13 AC 86 ms
72,576 KB
testcase_14 AC 85 ms
72,280 KB
testcase_15 AC 85 ms
72,196 KB
testcase_16 AC 86 ms
72,432 KB
testcase_17 AC 84 ms
72,064 KB
testcase_18 AC 86 ms
71,912 KB
testcase_19 AC 84 ms
72,360 KB
testcase_20 AC 86 ms
72,364 KB
testcase_21 AC 95 ms
72,456 KB
testcase_22 AC 85 ms
72,188 KB
testcase_23 AC 278 ms
108,348 KB
testcase_24 WA -
testcase_25 AC 86 ms
72,176 KB
testcase_26 AC 89 ms
72,296 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, random
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
    for i in range(n, 1, -1):
        x = y = 0
        while(x == y):
            x, y = random.randint(1, i), random.randint(1, i)
            if(x > y):
                x, y = y, x
        ops.append((x, y))

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