結果

問題 No.2784 繰り上がりなし十進和
ユーザー atcoder8atcoder8
提出日時 2024-06-14 22:49:10
言語 Rust
(1.77.0)
結果
AC  
実行時間 1,626 ms / 2,000 ms
コード長 879 bytes
コンパイル時間 11,426 ms
コンパイル使用メモリ 379,672 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-14 22:50:13
合計ジャッジ時間 30,071 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
5,248 KB
testcase_01 AC 29 ms
5,248 KB
testcase_02 AC 1,626 ms
5,376 KB
testcase_03 AC 31 ms
5,376 KB
testcase_04 AC 29 ms
5,376 KB
testcase_05 AC 29 ms
5,376 KB
testcase_06 AC 30 ms
5,376 KB
testcase_07 AC 30 ms
5,376 KB
testcase_08 AC 33 ms
5,376 KB
testcase_09 AC 36 ms
5,376 KB
testcase_10 AC 35 ms
5,376 KB
testcase_11 AC 35 ms
5,376 KB
testcase_12 AC 1,512 ms
5,376 KB
testcase_13 AC 1,575 ms
5,376 KB
testcase_14 AC 452 ms
5,376 KB
testcase_15 AC 108 ms
5,376 KB
testcase_16 AC 211 ms
5,376 KB
testcase_17 AC 717 ms
5,376 KB
testcase_18 AC 693 ms
5,376 KB
testcase_19 AC 209 ms
5,376 KB
testcase_20 AC 1,114 ms
5,376 KB
testcase_21 AC 198 ms
5,376 KB
testcase_22 AC 907 ms
5,376 KB
testcase_23 AC 122 ms
5,376 KB
testcase_24 AC 407 ms
5,376 KB
testcase_25 AC 711 ms
5,376 KB
testcase_26 AC 1,120 ms
5,376 KB
testcase_27 AC 1,163 ms
5,376 KB
testcase_28 AC 390 ms
5,376 KB
testcase_29 AC 1,108 ms
5,376 KB
testcase_30 AC 392 ms
5,376 KB
testcase_31 AC 201 ms
5,376 KB
testcase_32 AC 533 ms
5,376 KB
testcase_33 AC 619 ms
5,376 KB
testcase_34 AC 387 ms
5,376 KB
testcase_35 AC 142 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

const MAX: usize = 10_usize.pow(6);

fn main() {
    input! {
        aa: [usize; 6],
    }

    let mut visited = vec![false; MAX];
    for &a in &aa {
        visited[a] = true;

        for _ in 0..10 {
            for from in 0..MAX {
                if visited[from] {
                    let to = add_without_carry_up(from, a);
                    visited[to] = true;
                }
            }
        }
    }

    let ans = visited.iter().filter(|&&v| v).count();
    println!("{}", ans);
}

fn add_without_carry_up(a1: usize, a2: usize) -> usize {
    let s1 = format!("{:06}", a1);
    let s2 = format!("{:06}", a2);

    let mut c = 0;
    for (c1, c2) in s1.chars().zip(s2.chars()) {
        let d1 = c1.to_digit(10).unwrap() as usize;
        let d2 = c2.to_digit(10).unwrap() as usize;
        c = 10 * c + (d1 + d2) % 10;
    }

    c
}
0