結果

問題 No.1880 Many Ways
ユーザー lam6er
提出日時 2025-04-16 16:50:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,289 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 81,476 KB
実行使用メモリ 53,428 KB
最終ジャッジ日時 2025-04-16 16:51:49
合計ジャッジ時間 16,387 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    A = int(sys.stdin.readline())
    
    if A == 0:
        print("2 0")
        return
    elif A == 1:
        print("1 0")
        return
    
    factors = []
    current = A
    while current > 1:
        found = False
        start = min(current, 126)
        for i in range(start, 1, -1):
            if current % i == 0:
                factors.append(i)
                current = current // i
                found = True
                break
        if not found:
            factors.append(current)
            break
    
    sum_factors = sum(factors)
    if sum_factors + 2 > 128:
        print("Impossible case handled inadequately in this code.")
        return
    
    nodes = [[1]]
    current_node = 1
    for k in factors:
        next_nodes = []
        for _ in range(k):
            current_node += 1
            next_nodes.append(current_node)
        nodes.append(next_nodes)
    final_node = current_node + 1
    nodes.append([final_node])
    
    edges = []
    for i in range(len(nodes) - 1):
        for a in nodes[i]:
            for b in nodes[i+1]:
                edges.append((a, b))
    
    N = final_node
    M = len(edges)
    print(N, M)
    for a, b in edges:
        print(a, b)

if __name__ == "__main__":
    main()
0