結果
| 問題 |
No.2929 Miracle Branch
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2024-10-14 15:30:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 794 bytes |
| コンパイル時間 | 385 ms |
| コンパイル使用メモリ | 82,096 KB |
| 実行使用メモリ | 94,208 KB |
| 最終ジャッジ日時 | 2024-10-14 15:30:17 |
| 合計ジャッジ時間 | 10,955 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 18 |
ソースコード
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f <= INF and f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
X = int(input())
INF = 2 * 10 ** 5
D = prime_factorize(X)[::-1]
if D == []:
D = [1]
D2 = []
while len(D) >= 2 and D[-2:] == [2,2]:
D.pop()
D.pop()
D2.append(4)
D += D2
ans = len(D) + sum(D)
if ans > INF:
print(-1)
exit()
b = len(D)
UV = []
tmp = b
for i in range(b):
if i > 0:
UV.append((0, i))
for d in range(D[i]):
UV.append((i, tmp))
tmp += 1
else:
print(ans)
for u, v in UV:
print(u + 1, v + 1)
C = ["b"] * b + ["g"] * (ans - b)
print(*C)
ntuda