結果

問題 No.2479 Sum of Squares
ユーザー atcoder8atcoder8
提出日時 2023-09-22 21:31:00
言語 Rust
(1.77.0)
結果
AC  
実行時間 367 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 7,045 ms
コンパイル使用メモリ 145,880 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 21:31:11
合計ジャッジ時間 10,140 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 367 ms
4,376 KB
testcase_04 AC 122 ms
4,376 KB
testcase_05 AC 70 ms
4,376 KB
testcase_06 AC 84 ms
4,376 KB
testcase_07 AC 80 ms
4,376 KB
testcase_08 AC 104 ms
4,380 KB
testcase_09 AC 90 ms
4,380 KB
testcase_10 AC 99 ms
4,376 KB
testcase_11 AC 90 ms
4,376 KB
testcase_12 AC 101 ms
4,380 KB
testcase_13 AC 66 ms
4,380 KB
testcase_14 AC 85 ms
4,376 KB
testcase_15 AC 84 ms
4,380 KB
testcase_16 AC 92 ms
4,376 KB
testcase_17 AC 89 ms
4,380 KB
testcase_18 AC 85 ms
4,380 KB
testcase_19 AC 95 ms
4,380 KB
testcase_20 AC 94 ms
4,376 KB
testcase_21 AC 79 ms
4,376 KB
testcase_22 AC 89 ms
4,380 KB
testcase_23 AC 77 ms
4,376 KB
testcase_24 AC 87 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut s = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<usize>().unwrap()
    };

    let mut aa = vec![];
    while s != 0 {
        let sqrt_a = (2_usize..).find(|&a| a.pow(2) > s).unwrap() - 1;
        aa.push(sqrt_a.pow(2));
        s -= sqrt_a.pow(2);
    }

    println!("{}", aa.len());
    println!(
        "{}",
        aa.iter()
            .map(|a| a.to_string())
            .collect::<Vec<String>>()
            .join(" ")
    );
}
0