結果
| 問題 |
No.2519 Coins in Array
|
| コンテスト | |
| ユーザー |
MasKoaTS
|
| 提出日時 | 2023-08-30 17:22:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 811 bytes |
| コンパイル時間 | 289 ms |
| コンパイル使用メモリ | 82,108 KB |
| 実行使用メモリ | 120,816 KB |
| 最終ジャッジ日時 | 2024-06-23 12:23:18 |
| 合計ジャッジ時間 | 10,281 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 37 |
ソースコード
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 = [(a[0], a[1])]
elif(n == 3):
for p in permutations(a):
x = f(p[0], p[1]); y = f(x, p[2])
if(ans >= y):
ans = y
ops = [(p[0], p[1]), (x, p[2])]
x = f(p[1], p[2]); y = f(x, p[0])
if(ans >= y):
ans = y
ops = [(p[1], p[2]), (x, p[0])]
else:
ans = 0
ops = [(a[0], a[1]), (a[2], a[3]), (f(a[0], a[1]), f(a[2], a[3]))]
for i in range(4, n):
ops.append((0, a[i]))
print(ans)
for x, y in ops:
print(x, y)
MasKoaTS