結果
問題 |
No.2519 Coins in Array
|
ユーザー |
![]() |
提出日時 | 2023-09-03 12:41:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 859 bytes |
コンパイル時間 | 312 ms |
コンパイル使用メモリ | 82,684 KB |
実行使用メモリ | 106,116 KB |
最終ジャッジ日時 | 2024-06-23 12:24:06 |
合計ジャッジ時間 | 8,853 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 15 |
ソースコード
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)