結果

問題 No.2929 Miracle Branch
ユーザー 寝癖
提出日時 2024-10-12 17:00:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 878 ms
コンパイル使用メモリ 82,004 KB
実行使用メモリ 83,992 KB
最終ジャッジ日時 2024-10-12 17:03:04
合計ジャッジ時間 9,808 ms
ジャッジサーバーID
(参考情報)
judge / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

X = int(input())

M = 2*10**5

def prime_factorize(n):
    res = []
    for i in range(2, M+1):
        if i*i > n:
            break
        if n % i != 0:
            continue
        while n % i == 0:
            n //= i
            res.append(i)
    if n != 1 or len(res) == 0:
        res.append(n)
    return res

pf = prime_factorize(X)
if len(pf) + sum(pf) > M:
    print(-1)
    exit()

print(len(pf) + sum(pf))
c = ['b']*len(pf) + ['g']*sum(pf)
for i in range(len(pf)-1):
    print(i+1, i+2)

ind = len(pf)
for i in range(len(pf)):
    for j in range(pf[i]):
        print(i+1, ind+j+1)
    ind += pf[i]
print(*c)
0