結果

問題 No.2929 Miracle Branch
ユーザー tnodinotnodino
提出日時 2024-10-05 17:55:30
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 1,317 bytes
コンパイル時間 12,448 ms
コンパイル使用メモリ 378,988 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-10-05 17:55:49
合計ジャッジ時間 18,683 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 WA -
testcase_02 AC 1 ms
6,816 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 3 ms
5,248 KB
testcase_29 AC 3 ms
5,248 KB
testcase_30 AC 3 ms
5,248 KB
testcase_31 AC 3 ms
5,248 KB
testcase_32 AC 3 ms
5,248 KB
testcase_33 AC 2 ms
5,248 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
5,248 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;
use proconio::fastout;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        mut X: usize,
    }
    assert!(1 <= X && X <= 1_000_000_000_000_000_000);
    if X == 1 {
        println!("2");
        println!("1 2");
        println!("b g");
        return;
    }
    let n = (X as f64).sqrt() as usize;
    let mut p = Vec::new();
    while X % 4 == 0 {
        p.push(4);
        X /= 4;
    }
    for i in 2..=n {
        if i >= 200000 {
            if X == 1 {
                break;
            }
            println!("-1");
            return;
        }
        while X % i == 0 {
            p.push(i);
            X /= i;
        }
    }
    if X > 1 {
        p.push(X);
    }
    let N = p.len();
    let s = p.iter().sum::<usize>();
    if N + s > 200_000 {
        println!("-1");
        return;
    }
    println!("{}", N + s);
    let mut j = N;
    for i in 0..N {
        for _ in 0..p[i] {
            println!("{} {}", i+1, j+1);
            j += 1;
        }
        println!("{} {}", j-1, j);
        if i < N - 1 {
            println!("{} {}", i+1, i+2);
        }
    }
    println!("{} {}", "b".repeat(N).chars().map(|x| x.to_string()).collect::<Vec<String>>().join(" "), "g".repeat(s).chars().map(|x| x.to_string()).collect::<Vec<String>>().join(" "));
}
0