結果

問題 No.2519 Coins in Array
ユーザー MasKoaTSMasKoaTS
提出日時 2023-10-27 12:43:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 1,369 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 125,004 KB
最終ジャッジ日時 2023-10-27 12:43:34
合計ジャッジ時間 12,592 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
85,744 KB
testcase_01 AC 117 ms
85,748 KB
testcase_02 AC 118 ms
85,680 KB
testcase_03 AC 119 ms
85,744 KB
testcase_04 AC 121 ms
85,748 KB
testcase_05 AC 120 ms
85,748 KB
testcase_06 AC 122 ms
85,748 KB
testcase_07 AC 122 ms
85,744 KB
testcase_08 AC 141 ms
85,748 KB
testcase_09 AC 120 ms
85,744 KB
testcase_10 AC 122 ms
85,748 KB
testcase_11 AC 122 ms
85,748 KB
testcase_12 AC 124 ms
85,748 KB
testcase_13 AC 118 ms
85,740 KB
testcase_14 AC 124 ms
85,748 KB
testcase_15 AC 120 ms
85,684 KB
testcase_16 AC 123 ms
85,744 KB
testcase_17 AC 124 ms
85,748 KB
testcase_18 AC 120 ms
85,748 KB
testcase_19 AC 120 ms
85,684 KB
testcase_20 AC 120 ms
85,680 KB
testcase_21 AC 123 ms
85,680 KB
testcase_22 AC 124 ms
85,748 KB
testcase_23 AC 242 ms
120,328 KB
testcase_24 AC 251 ms
120,068 KB
testcase_25 AC 121 ms
85,684 KB
testcase_26 AC 122 ms
85,680 KB
testcase_27 AC 246 ms
120,328 KB
testcase_28 AC 257 ms
120,328 KB
testcase_29 AC 241 ms
120,328 KB
testcase_30 AC 228 ms
116,528 KB
testcase_31 AC 161 ms
92,216 KB
testcase_32 AC 213 ms
103,432 KB
testcase_33 AC 213 ms
110,732 KB
testcase_34 AC 182 ms
99,856 KB
testcase_35 AC 207 ms
108,192 KB
testcase_36 AC 171 ms
96,996 KB
testcase_37 AC 164 ms
90,756 KB
testcase_38 AC 202 ms
105,420 KB
testcase_39 AC 177 ms
98,456 KB
testcase_40 AC 241 ms
125,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from functools import cmp_to_key
import math
import sys
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
sys.setrecursionlimit(10 ** 6)
inp = sys.stdin.readline
input = lambda : inp()[:-1]
getN = lambda : int(inp())
getNs = lambda : map(int, inp().split())
getList = lambda :list(map(int, inp().split()))
getStrs = lambda n : [input() for _ in [0] * n]
getEdges = lambda n : [[x - 1 for x in getNs()] for _ in [0] * n]
def yexit(): print("Yes"); exit(0)
def nexit(): print("No"); exit(0)
pi = 3.141592653589793
mod = 1000000007
MOD = 998244353
INF = 4611686018427387903
dx = [1, 0, -1, 0];  dy = [0, 1, 0, -1]
#di = coll.defaultdict(int)

def f(x, y):
    if(math.gcd(x, y) != 1):
        return 0
    return (x - 1) * (y - 1)
 
"""
Main Code
"""

n = getN()
a = getList()

ans = INF
ops = []
if(n == 2):
    ans = f(a[0], a[1])
    ops = [(1, 2)]
elif(n == 3):
    ans_lis = [f(f(a[0], a[1]), a[2]), f(f(a[0], a[2]), a[1]), f(f(a[1], a[2]), a[0])]
    ops_lis = [[(1, 2), (1, 2)], [(1, 3), (1, 2)], [(2, 3), (1, 2)]]
    for x, y in zip(ans_lis, ops_lis):
        if(ans <= x):
            continue
        ans, ops = x, y
else:
    ans = 0
    ops = [(1, 2) for _ in [0] * (n - 1)]

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