結果

問題 No.1085 桁和の桁和
ユーザー tonyu0tonyu0
提出日時 2020-06-20 00:58:52
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 3,005 ms
コンパイル使用メモリ 147,740 KB
実行使用メモリ 14,088 KB
最終ジャッジ日時 2023-09-30 06:29:02
合計ジャッジ時間 5,560 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 16 ms
6,300 KB
testcase_15 AC 35 ms
12,440 KB
testcase_16 AC 36 ms
12,176 KB
testcase_17 AC 18 ms
6,624 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 33 ms
11,108 KB
testcase_20 WA -
testcase_21 AC 21 ms
7,704 KB
testcase_22 AC 30 ms
10,460 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 19 ms
7,072 KB
testcase_26 AC 39 ms
12,660 KB
testcase_27 AC 31 ms
10,548 KB
testcase_28 AC 43 ms
14,000 KB
testcase_29 AC 23 ms
8,220 KB
testcase_30 AC 21 ms
7,704 KB
testcase_31 AC 37 ms
12,184 KB
testcase_32 AC 27 ms
9,012 KB
testcase_33 AC 62 ms
14,064 KB
testcase_34 AC 64 ms
14,024 KB
testcase_35 AC 65 ms
14,016 KB
testcase_36 AC 66 ms
14,056 KB
testcase_37 AC 63 ms
14,064 KB
testcase_38 AC 62 ms
14,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;
const MOD: usize = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    let n = s.len();
    let d: usize = itr.next().unwrap().parse().unwrap();

    let mut dp = vec![vec![0; 10]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..10 {
            // 桁和がjの場合から遷移
            if s[i] == '?' {
                for k in 0..10 {
                    dp[i + 1][(j * 10 + k) % 9] += dp[i][j];
                    dp[i + 1][(j * 10 + k) % 9] %= MOD;
                }
            } else {
                let x = (s[i] as u8 - '0' as u8) as usize;
                dp[i + 1][(j * 10 + x) % 9] += dp[i][j];
                dp[i + 1][(j * 10 + x) % 9] %= MOD;
            }
        }
    }
    println!("{}", dp[n][d % 9]);
}
0