結果

問題 No.2519 Coins in Array
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-10-28 09:45:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 2,744 ms
コンパイル使用メモリ 81,660 KB
実行使用メモリ 106,280 KB
最終ジャッジ日時 2023-10-28 09:45:27
合計ジャッジ時間 7,109 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,784 KB
testcase_01 AC 36 ms
53,784 KB
testcase_02 AC 36 ms
53,720 KB
testcase_03 AC 39 ms
53,784 KB
testcase_04 AC 36 ms
53,784 KB
testcase_05 AC 36 ms
53,784 KB
testcase_06 AC 37 ms
53,784 KB
testcase_07 AC 37 ms
53,784 KB
testcase_08 AC 36 ms
53,784 KB
testcase_09 AC 36 ms
53,784 KB
testcase_10 AC 36 ms
53,784 KB
testcase_11 AC 36 ms
53,784 KB
testcase_12 AC 35 ms
53,784 KB
testcase_13 AC 36 ms
53,784 KB
testcase_14 AC 35 ms
53,784 KB
testcase_15 AC 35 ms
53,720 KB
testcase_16 AC 36 ms
53,784 KB
testcase_17 AC 36 ms
53,784 KB
testcase_18 AC 36 ms
53,784 KB
testcase_19 AC 36 ms
53,720 KB
testcase_20 AC 35 ms
53,720 KB
testcase_21 AC 39 ms
53,720 KB
testcase_22 AC 36 ms
53,784 KB
testcase_23 AC 144 ms
106,252 KB
testcase_24 AC 146 ms
105,920 KB
testcase_25 AC 36 ms
53,732 KB
testcase_26 AC 35 ms
53,732 KB
testcase_27 AC 142 ms
106,280 KB
testcase_28 AC 170 ms
106,280 KB
testcase_29 AC 144 ms
106,280 KB
testcase_30 AC 137 ms
102,696 KB
testcase_31 AC 70 ms
78,692 KB
testcase_32 AC 100 ms
89,580 KB
testcase_33 AC 120 ms
96,572 KB
testcase_34 AC 88 ms
84,712 KB
testcase_35 AC 115 ms
94,196 KB
testcase_36 AC 80 ms
82,324 KB
testcase_37 AC 67 ms
77,596 KB
testcase_38 AC 106 ms
91,712 KB
testcase_39 AC 91 ms
83,500 KB
testcase_40 AC 167 ms
103,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n = int(input())
A = list(map(int,input().split()))


def f(A,inds):
    ans = [[inds[-1],inds[-2]]]
    
    a1,a2 = A[-1],A[-2]
    num = 10**18
    if math.gcd(a1,a2) != 1:
        num = 0
    else:
        num = (a1-1)*(a2-1)

    for i in range(len(A)-2):
        if math.gcd(num,A[0]) != 1:
            num = 0
        if num:
            num = (num-1) * (A[0]-1)
        ans.append([1,2])
    
    return num,ans

if n >= 4:
    print(0)
    for i in range(n-1):
        print(1,2)

else:

    inds = [i+1 for i in range(n)]

    res = 10**18
    ans = []
    for i in range(n):
        num,ans2 = f(A,inds)
        if num < res:
            res = num
            ans = ans2
        
        inds = inds[1:] + [inds[0]]
        A = A[1:] + [A[0]]
    
    print(res)
    for a in ans:
        print(*a)
0