結果
問題 | No.2519 Coins in Array |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2023-10-27 23:49:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,827 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 82,632 KB |
実行使用メモリ | 107,068 KB |
最終ジャッジ日時 | 2024-09-25 15:35:30 |
合計ジャッジ時間 | 7,149 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,716 KB |
testcase_01 | AC | 40 ms
54,620 KB |
testcase_02 | AC | 41 ms
58,968 KB |
testcase_03 | AC | 41 ms
58,620 KB |
testcase_04 | AC | 38 ms
53,420 KB |
testcase_05 | AC | 38 ms
52,672 KB |
testcase_06 | AC | 38 ms
53,060 KB |
testcase_07 | WA | - |
testcase_08 | AC | 39 ms
53,644 KB |
testcase_09 | WA | - |
testcase_10 | AC | 38 ms
53,756 KB |
testcase_11 | AC | 42 ms
59,480 KB |
testcase_12 | AC | 43 ms
58,980 KB |
testcase_13 | WA | - |
testcase_14 | AC | 38 ms
52,896 KB |
testcase_15 | AC | 40 ms
53,320 KB |
testcase_16 | AC | 39 ms
53,356 KB |
testcase_17 | AC | 39 ms
53,200 KB |
testcase_18 | AC | 42 ms
53,000 KB |
testcase_19 | AC | 38 ms
52,532 KB |
testcase_20 | AC | 38 ms
53,376 KB |
testcase_21 | AC | 41 ms
58,736 KB |
testcase_22 | AC | 38 ms
53,496 KB |
testcase_23 | AC | 153 ms
107,048 KB |
testcase_24 | AC | 159 ms
107,004 KB |
testcase_25 | AC | 39 ms
53,800 KB |
testcase_26 | AC | 38 ms
54,524 KB |
testcase_27 | AC | 155 ms
106,708 KB |
testcase_28 | AC | 160 ms
106,888 KB |
testcase_29 | AC | 155 ms
107,068 KB |
testcase_30 | AC | 150 ms
103,592 KB |
testcase_31 | AC | 78 ms
79,168 KB |
testcase_32 | AC | 108 ms
90,152 KB |
testcase_33 | RE | - |
testcase_34 | AC | 94 ms
85,280 KB |
testcase_35 | RE | - |
testcase_36 | AC | 89 ms
83,088 KB |
testcase_37 | AC | 73 ms
77,932 KB |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | AC | 150 ms
104,536 KB |
ソースコード
import math n = int(input()) A = list(map(int,input().split())) if 1 in A: assert False print(1) f = A.index(1) + 1 s = 2 if f == 1 else 1 print(f,s) for i in range(n-2): print(n-1-i,1) exit() if 0 in A: print(0) f = A.index(0) + 1 s = 2 if f == 1 else 1 print(f,s) for i in range(n-2): print(n-1-i,1) exit() dic = {} target = [] for i,a in enumerate(A,1): now = a for j in range(2,int(a**0.5)+1): if now%j: continue if j in dic: target = [i,dic[j]] break while now % j == 0: now //= j dic[j] = i if now == 1: continue j = now if j in dic: target = [i,dic[j]] break dic[j] = i if target: print(0) assert target[0] != target[1] print(*target) for i in range(n-2): print(1,n-1-i) exit() even = [] odd = [] for i,a in enumerate(A,1): if a%2: odd.append(i) else: even.append(i) def get(A): ret = 10**20 for i in range(len(A)): ans = (A[0]-1) * (A[1]-1) for i in range(2,n): if math.gcd(ans,A[i]) != 1: return 0 ans = (ans-1)*(A[i]-1) ret = min(ret,ans) A = A[1:] + [A[0]] return ret if (n == 3 and even == []) or n == 2: print(get(A)) for i in range(n-1): print(1,2) exit() print(0) assert len(even) < 2 if even: f = odd.pop() s = odd.pop() print(f,s) x = even[0] m = 0 if x > f: m += 1 if x > s: m += 1 x -= m print(x,n-1) for i in range(n-3): print(1,n-2-i) else: print(1,2) print(1,2) print(n-2,n-3) for i in range(n-4): print(1,n-3-i)